/*! Andrew.Pc.Plugin by jQuery PcWebSite Script v2.3.0 --- Copyright Andrew.Kim | (c) 20171015 ~ 20180125 andrew.pc.plugin.js license */
/*! Coding by Andrew.Kim (E-mail: andrewkim365@qq.com) */

if ("undefined" == typeof jQuery) throw new Error("Andrew PcWebSite Plugin's JavaScript requires jQuery");
jQuery.easing['jswing'] = jQuery.easing['swing'];
jQuery.extend(jQuery.easing, {
    def: 'easeOutQuad',
    swing: function (x, t, b, c, d) {
        //alert(jQuery.easing.default);
        return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
    },
    easeInQuad: function (x, t, b, c, d) {
        return c*(t/=d)*t + b;
    },
    easeOutQuad: function (x, t, b, c, d) {
        return -c *(t/=d)*(t-2) + b;
    },
    easeInOutQuad: function (x, t, b, c, d) {
        if ((t/=d/2) < 1) return c/2*t*t + b;
        return -c/2 * ((--t)*(t-2) - 1) + b;
    },
    easeInCubic: function (x, t, b, c, d) {
        return c*(t/=d)*t*t + b;
    },
    easeOutCubic: function (x, t, b, c, d) {
        return c*((t=t/d-1)*t*t + 1) + b;
    },
    easeInOutCubic: function (x, t, b, c, d) {
        if ((t/=d/2) < 1) return c/2*t*t*t + b;
        return c/2*((t-=2)*t*t + 2) + b;
    },
    easeInQuart: function (x, t, b, c, d) {
        return c*(t/=d)*t*t*t + b;
    },
    easeOutQuart: function (x, t, b, c, d) {
        return -c * ((t=t/d-1)*t*t*t - 1) + b;
    },
    easeInOutQuart: function (x, t, b, c, d) {
        if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
        return -c/2 * ((t-=2)*t*t*t - 2) + b;
    },
    easeInQuint: function (x, t, b, c, d) {
        return c*(t/=d)*t*t*t*t + b;
    },
    easeOutQuint: function (x, t, b, c, d) {
        return c*((t=t/d-1)*t*t*t*t + 1) + b;
    },
    easeInOutQuint: function (x, t, b, c, d) {
        if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
        return c/2*((t-=2)*t*t*t*t + 2) + b;
    },
    easeInSine: function (x, t, b, c, d) {
        return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
    },
    easeOutSine: function (x, t, b, c, d) {
        return c * Math.sin(t/d * (Math.PI/2)) + b;
    },
    easeInOutSine: function (x, t, b, c, d) {
        return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
    },
    easeInExpo: function (x, t, b, c, d) {
        return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
    },
    easeOutExpo: function (x, t, b, c, d) {
        return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
    },
    easeInOutExpo: function (x, t, b, c, d) {
        if (t==0) return b;
        if (t==d) return b+c;
        if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
        return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
    },
    easeInCirc: function (x, t, b, c, d) {
        return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
    },
    easeOutCirc: function (x, t, b, c, d) {
        return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
    },
    easeInOutCirc: function (x, t, b, c, d) {
        if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
        return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
    },
    easeInElastic: function (x, t, b, c, d) {
        var s=1.70158;var p=0;var a=c;
        if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
        if (a < Math.abs(c)) { a=c; var s=p/4; }
        else var s = p/(2*Math.PI) * Math.asin (c/a);
        return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
    },
    easeOutElastic: function (x, t, b, c, d) {
        var s=1.70158;var p=0;var a=c;
        if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
        if (a < Math.abs(c)) { a=c; var s=p/4; }
        else var s = p/(2*Math.PI) * Math.asin (c/a);
        return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
    },
    easeInOutElastic: function (x, t, b, c, d) {
        var s=1.70158;var p=0;var a=c;
        if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
        if (a < Math.abs(c)) { a=c; var s=p/4; }
        else var s = p/(2*Math.PI) * Math.asin (c/a);
        if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
        return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
    },
    easeInBack: function (x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        return c*(t/=d)*t*((s+1)*t - s) + b;
    },
    easeOutBack: function (x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
    },
    easeInOutBack: function (x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
        return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
    },
    easeInBounce: function (x, t, b, c, d) {
        return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
    },
    easeOutBounce: function (x, t, b, c, d) {
        if ((t/=d) < (1/2.75)) {
            return c*(7.5625*t*t) + b;
        } else if (t < (2/2.75)) {
            return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
        } else if (t < (2.5/2.75)) {
            return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
        } else {
            return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
        }
    },
    easeInOutBounce: function (x, t, b, c, d) {
        if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
        return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
    }
});

/*-----------------------------------------------Andrew_Config-------------------------------------------*/
function Andrew_Config(setting){
    var option = $.extend({
            MaskStyle: "",
            ResizeRefresh: false,
            FooterFix: false,
            AnimatedSleep: true
        },
        setting);
    var isIE = function () {
        var U = navigator.userAgent,
            IsIE = U.indexOf('MSIE') > -1,
            a = IsIE ? /\d+/.exec(U.split(';')[1]) : 'no ie';return a <= 8;
    }();
    if(option.MaskStyle) {
        $("html").addClass("ak-mask_" + option.MaskStyle[0]+" ak-mask_"+option.MaskStyle[1]);
    }
    if(option.ResizeRefresh== true) {
        if(!isIE){
            $(window).resize(function(){
                window.location.reload();
            });
        }
    }
    if(option.AnimatedSleep== true) {
        $("*[data-animated]").each(function () {
            var ani = $(this);
            ani.addClass("animated");
            ani.addClass(ani.attr("data-animated"));
            setInterval(function(){
                    ani.removeClass("animated");
                    ani.removeClass(ani.attr("data-animated"));
                    setTimeout(function() {
                            ani.addClass("animated");
                            ani.addClass(ani.attr("data-animated"));
                        },
                        ani.attr("data-anisleep"));
                },
                ani.attr("data-anisleep")
            );
        });
    }
    if(option.FooterFix== true) {
        $(function () {
            $(window).each(function () {
                if ($("body").height() < $(window).height()) {
                    $("footer").addClass("fix bottom_0");
                    if ($("body").height() > $("footer").offset().top) {
                        $("footer").removeClass("fix bottom_0");
                        $("footer").addClass("mt_1em rel").css({
                            "bottom":"-5px"
                        });
                    }
                } else {
                    $("footer").removeClass("fix bottom_0");
                }
            });
            if(!isIE) {
                document.addEventListener('mousemove', function () {
                    if ($("body").height() < $(window).height()) {
                        $("footer").addClass("fix bottom_0");
                        if ($("body").height() > $("footer").offset().top) {
                            $("footer").removeClass("fix bottom_0");
                            $("footer").addClass("mt_1em rel").css({
                                "bottom": "-5px"
                            });
                        }
                    } else {
                        $("footer").removeClass("fix bottom_0");
                    }
                }, false);
            }
        });
    } else {
        $(function () {
            $("footer").removeClass("fix bottom_0");
        });
    }
}

/*-----------------------------------------------Andrew_Router------------------------------------------*/
function Andrew_Router(setting){
    var option = $.extend({
            Router: false,
            success:function () {
            },
            error:function () {
            },
            changePage:function () {
            }
        },
        setting);
    if (option.Router == true) {
        $(window).each(function () {
            if (location.hash.substring(1) != "") {
                htmlobj = $.ajax({
                    url: location.hash.substring(1),
                    async: false,
                    success: function () {
                        hash = location.hash.substring(1);
                        option.success(hash);
                        $("body").show();
                    },
                    error: function () {
                        hash = location.hash.substring(1);
                        option.error(hash);
                        $("body").hide();
                    }
                });
                $("body").html(htmlobj.responseText);
                Andrew_HashSharp();
            }
            option.changePage(location.hash.substring(1));
        });
        $(window).bind('hashchange', function () {

            if (location.hash.substring(1) != "") {
                htmlobj = $.ajax({
                    url: location.hash.substring(1),
                    async: false,
                    success: function () {
                        hash = location.hash.substring(1);
                        option.success(hash);
                        $("body").show();
                    },
                    error: function () {
                        hash = location.hash.substring(1);
                        option.error(hash);
                        $("body").hide();
                    }
                });
                $("body").html(htmlobj.responseText);
                Andrew_HashSharp();
                $('body').animate({"scrollTop": 0}, 100);
            } else {
                window.location.reload();
            }
            option.changePage(location.hash.substring(1));
        });
    }
}

/*-----------------------------------------------Andrew_Ajax-------------------------------------------*/
function Andrew_Ajax(setting){
    var option = $.extend({
            to: "",
            type: "POST",
            url: "",
            data:{},
            async:false,
            success:function () {
            },
            error:function () {
            }
        },
        setting);
    htmlobj=$.ajax({
        type : option.type,
        url: option.url,
        data: option.data,
        async: option.async,
        success:function (result) {
            option.success(result);
            if($(option.to)){
                $(option.to).html(htmlobj.responseText);
            }
            Andrew_HashSharp();
        },
        error:function (error) {
            if($(option.to)){
                $(option.to).html(htmlobj.responseText);
            }
            option.error(error);
        }
    });
}

/*-----------------------------------------------Andrew_GoTop-------------------------------------------*/
function Andrew_GoTop (setting){
    option = $.extend({
        hide: false,
        url: "",
        icon: "",
        state: "bottom",
        height: "40px",
        width: "40px",
        time: 500,
        scrollTop: 400,
        aimation: "show",
        hidetime: 2000,
        toTop :function () {},
        toShow :function () {},
        toHide :function () {},
        ak_Go :function () {}
    },setting);
    var sate,
        timer=null;
    if(option.state=='center'){
        sate='top:50%';
    }
    else if(option.state=='bottom'){
        sate= 'bottom:10%'
    }
    if(!option.icon || option.url) {
        var dom = '<div class="ak-GoTopBox" style="width:' + option.width + ';height:' + option.height + ';display:none;position:fixed;cursor:pointer;right:2em;z-index:999;' + sate + '">' +
            '<img src=' + option.url + ' style="width:100%" />' +
            '</div>'
    } else {
        var dom = '<div class="ak-GoTopBox ' + option.icon + '" style="width:' + option.width + ';height:' + option.height + ';display:none;position:fixed;cursor:pointer;right:2em;z-index:999;' + sate + '">' +
            '</div>'
    }
    $('body').append(dom);
    var GoTopBox = $('.ak-GoTopBox');
    $(window).on('scroll',throttle(scroll,50));
    function scroll(){
        if($(window).scrollTop()>=option.scrollTop){
            GoTopBox.fadeIn().addClass(option.aimation);
            if(option.hide){
                clearTimeout(timer);
                timer=setTimeout(function(){
                    GoTopBox.fadeOut();
                    option.toHide&&option.toHide();
                },2000)
            }
            option.toShow&&option.toShow();
        }else{
            if(GoTopBox.css('display')=='block'){
                option.toHide&&option.toHide();
            }
            GoTopBox.hide().removeClass(option.aimation);

        }
        if($(window).scrollTop()<=5){
            option.toTop&&option.toTop();
        }
    }
    GoTopBox.on('click',function(){
        $('html,body').animate({scrollTop:0},500,function(){
            option.toTop&&option.toTop();
        });
        option.ak_Go&&option.ak_Go();
    });
    $(window).on('load',function(){
        if($(window).scrollTop()==0){
            return;
        }
        scroll();
    });
    GoTopBox.on('mouseenter',function(){
        clearTimeout(timer);
        GoTopBox.fadeIn();
    });
    GoTopBox.on('mouseleave',function(){
        timer=setTimeout(function(){
            GoTopBox.fadeOut();
            option.toHide&&option.toHide();
        },2000)
    });
    //公共函数
    //节流函数
    function throttle(fn,time){
        var timer=null;
        return function(){
            var ctx=this,arg=arguments;
            clearTimeout(timer);
            timer = setTimeout(function(){fn.apply(ctx,arg)},time)
        }
    }
}

/*-----------------------------------------------Andrew_Popupwin-------------------------------------------*/
function Andrew_Popupwin (setting){
    option = $.extend({
        dom: "",
        position: "",
        effectIn: "",
        effectOut: "",
        hasMask: true,
        closeBtn: "",
        OneButton: "",
        maskPosition: "",
        toggleIcon: "",
        callback :function () {},
        scrollback :function () {}
    },setting);

    if (option.dom) {
        $(option.dom).css({
            "position": "fixed",
            "z-index": parseInt(option.maskPosition)+1
        });

        var ww = $(window).width();
        var wh = $(window).height();
        var dw = $(option.dom).outerWidth();
        var dh = $(option.dom).outerHeight();

        if (option.position === 'top') {
            $(option.dom).css({
                "left": (ww / 2) - (dw / 2),
                "top": 0
            });
        } else if (option.position === 'bottom') {
            $(option.dom).css({
                "left": (ww / 2) - (dw / 2),
                "bottom": 0
            });
        } else if (option.position === 'left') {
            $(option.dom).css({
                "left": 0,
                "top": 0
            });
        } else if (option.position === 'right') {
            $(option.dom).css({
                "right": 0,
                "top": 0
            });
        } else if (option.position === 'offset') {
            var ot = $(option.OneButton).offset().top;
            var oh = $(option.OneButton).outerHeight();
            $(option.dom).css({
                "left": 0,
                "top": ot + oh
            });
        } else { // middle
            $(option.dom).css({
                "left": (ww / 2) - (dw / 2),
                "top": (wh / 2) - (dh / 2)
            });
        }
    }

    if (option.position === 'offset') {
        var main_scroll = $("main").scrollTop() + $(option.dom).outerHeight();
        $("main").scroll(function(sc){
            var scrolltop = $(this).scrollTop();
            if(scrolltop < main_scroll) {
                if ($(option.OneButton).hasClass("ak-is_active")) {
                    ClickHideModal();
                    $(option.dom).removeClass("dis_none");
                } else {
                    $(option.dom).removeAttr("style");
                }
            } else if(scrolltop > main_scroll) {
                if ($(option.OneButton).hasClass("ak-is_active")) {
                    ClickHideModal();
                    $(option.dom).removeClass("dis_none");
                } else {
                    $(option.dom).removeAttr("style");
                }
            }
            option.scrollback($(option));
            sc.preventDefault();
        });
    }
    if (option.hasMask) {
        addModalMask();
        $("main").removeClass("scrolling");
    }

    if (option.maskPosition) {
        $('#popup_mask').css({
            "z-index": option.maskPosition
        });
        if (option.position === 'offset') {
            var otm = $(option.OneButton).offset().top;
            var ohm = $(option.OneButton).outerHeight();
            $('#popup_mask').css({
                "top": otm + ohm
            });
        }
    }
    if (option.OneButton) {

        $(option.dom).on('click', function() {
            ClickHideModal();
        });

        $(option.OneButton).toggleClass("ak-is_active");
        if ($(option.OneButton).hasClass("ak-is_active")) {
            addModalMask();
            if (option.position === 'offset') {
                var oth = $(option.OneButton).offset().top + $(option.OneButton).outerHeight();
                $(option.dom).css({
                    "top": oth
                })
            }
            $(option.dom).removeClass("animated " + option.effectOut).addClass("animated " + option.effectIn).removeClass("dis_none");
            if (option.toggleIcon) {
                if (option.position != 'offset') {
                    $(option.OneButton).append("<i />");
                    $(option.OneButton).children("i").eq(0).hide();
                    $(option.OneButton).children("i").eq(1).addClass(option.toggleIcon);
                }
            }
            option.callback($(option));
        } else {
            ClickHideModal();
        }
    } else {
        $(option.dom).removeClass("animated " + option.effectOut).addClass("animated " + option.effectIn).removeClass("dis_none");
        addModalMask();
        option.callback($(option));
    }

    $(option.closeBtn).on('click', function(ec) {
        ec.preventDefault();
        ClickHideModal();
    });
    function addModalMask() {
        if ($("#popup_mask").length < 1) {
            $("body").append('<div id="popup_mask" class="ak-mask"></div>');
            $('#popup_mask').show();
        }
    }
    function ClickHideModal(){
        if (option.OneButton) {
            $(option.dom).removeClass("animated " + option.effectIn).addClass("animated " + option.effectOut);
            $(option.OneButton).children("i").eq(0).show();
            $(option.OneButton).children("i").eq(1).remove();
            $(option.OneButton).removeClass(option.toggleIcon);
        } else {
            if (option.effectOut) {
                $(option.dom).removeClass("animated " + option.effectIn).addClass("animated " + option.effectOut);
            }
        }
        setTimeout(function() {
            $("main").addClass("scrolling");
            $(option.OneButton).removeClass("ak-is_active");
            $('#popup_mask').fadeOut().remove();
            $(option.dom).addClass("dis_none").removeAttr("style");
        },1000);
    }
}

/*-----------------------------------------------Andrew_CountDown-------------------------------------------*/
function Andrew_CountDown(ele,setting){
    var option = $.extend({
            wait: 10,
            Start_text: "",
            End_Text: "",
            callback:function(){
            }
        },
        setting);
    var waits = option.wait;
    if (waits == 0) {
        ele.removeAttr("disabled");
        ele.html(option.End_Text);
        waits = option.wait;
        option.callback(waits);
    }
    else {
        ele.attr("disabled", "disabled");
        ele.html(waits + option.Start_text);
        waits--;
        setTimeout(function() {
                Andrew_CountDown(ele,{
                    wait: waits,
                    Start_text: option.Start_text,
                    End_Text: option.End_Text,
                    callback:function(waits){
                        option.callback(waits);
                    }
                })
            },
            1000)
    }
}

/*-----------------------------------------------Andrew_WebToast-------------------------------------------*/
function webToast(){
    var dcfg = {
        msg: "",
        postion: "bottom",
        time: 1000
    };
    var Andrew_WebToast = ".ak-webtoast";
    var sub_Andrew_WebToast = Andrew_WebToast.substring(1,Andrew_WebToast.length);
    var len = arguments.length;
    var arg0 = arguments[0];
    if (arguments.length > 0) {
        dcfg.msg = arguments[0];
        dcfg.msg = arg0;

        var arg1 = arguments[1];
        var regx = /(bottom|top|middle)/i;
        var regy = /()/i;
        var numRegx = /[1-9]\d*/;
        if (regx.test(arg1)) {
            dcfg.postion = arg1;
        } else if (regy.test(arg1)) {
            dcfg.mask = arg1;
        } else if (numRegx.test(arg1)) {
            dcfg.time = arg1;
        }

        var arg2 = arguments[2];
        var numRegx = /[1-9]\d*/;
        if (numRegx.test(arg2)) {
            dcfg.time = arg2;
        }
        if (regy.test(arg2)) {
            dcfg.mask = arg2;
        }
    }
    if ("ak-mask" == dcfg.mask) {
        var ret = "<div class='"+sub_Andrew_WebToast+" animated fadeIn'><div class='ak-mask'></div><h3>" + dcfg.msg + "</h3></div>";
    } else {
        var ret = "<div class='"+sub_Andrew_WebToast+" animated fadeIn'><h3>" + dcfg.msg + "</h3></div>";
    }
    if ($(Andrew_WebToast).length <= 0) {
        $("body").append(ret);
    } else {
        $(Andrew_WebToast).css("left", "");
        if ("ak-mask" == dcfg.mask) {
            ret = "<div class='ak-mask'></div><h3>" + dcfg.msg + "</h3>";
        } else {
            ret = "<h3>" + dcfg.msg + "</h3>";
        }
        $(Andrew_WebToast).html(ret);
    }
    var w = $(Andrew_WebToast).width(),
        ww = $(window).width();
    $(Andrew_WebToast).fadeIn();
    $(Andrew_WebToast).css("left", (ww - w) / 2 - 20);
    if ("bottom" == dcfg.postion) {
        $(Andrew_WebToast).css("bottom", 50);
        $(Andrew_WebToast).css("top", "");
    } else if ("top" == dcfg.postion) {
        $(Andrew_WebToast).css("bottom", "");
        $(Andrew_WebToast).css("top", 50);
    } else if ("middle" == dcfg.postion) {
        $(Andrew_WebToast).css("bottom", "");
        $(Andrew_WebToast).css("top", "");
        var h = $(Andrew_WebToast).height(),
            hh = $(window).height();
        $(Andrew_WebToast).css("bottom", (hh - h) / 2 - 20);
    }
    setTimeout(function() {
            $(Andrew_WebToast).fadeOut().remove();
        },
        dcfg.time);
}

/*-----------------------------------------------Andrew_HashSharp------------------------------------------*/
function Andrew_HashSharp() {
    $('*[data-href]').click(function () {
        //移动端不适合使用a元素，通过button的data-href设置跳转界面
        var hash_sharp = new RegExp("#");
        var hash_script = new RegExp("javascript");
        if (hash_sharp.test($(this).attr("data-href")) || hash_script.test($(this).attr("data-href"))) {
            window.location.href = $(this).attr("data-href");
        } else {
            window.location.href = "#"+ $(this).attr("data-href");
        }
    });
    $('form[action]').each(function () {
        //移动端不适合使用a元素，通过button的data-href设置跳转界面
        var hash_sharp = new RegExp("#");
        if (!hash_sharp.test($(this).attr("action"))) {
            $(this).attr("action","#"+ $(this).attr("action"));
        }
    });
}

/*-----------------------------------------------Andrew_Validate-------------------------------------------*/
(function($){
    /*************************策略对象*****************************/
    var RULES = {
        isNonEmpty: function(value, errorMsg) {
            //不能为空
            if (!value.length) {
                return errorMsg;
            }
        },
        minLength: function(value, length, errorMsg) {
            //大于
            if (value.length < length) {
                return errorMsg;
            }
        },
        maxLength: function(value, length, errorMsg) {
            //小于
            if (value.length < length) {
                return errorMsg;
            }
        },
        isMobile: function(value, errorMsg) {
            //是否为手机号码
            if (!/(^1[3|4|5|7|8|9][0-9]{9}$)/.test(value)) {
                return errorMsg;
            }
        },
        isEmail: function(value, errorMsg) {
            //是否为邮箱
            if (!/(^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$)/.test(value)) {
                return errorMsg;
            }
        },
        between: function(value, range, errorMsg) {
            //大于小于
            var min = parseInt(range.split('-')[0]);
            var max = parseInt(range.split('-')[1]);
            if (value.length < min || value.length > max) {
                return errorMsg;
            }
        },
        onlyEn: function(value, errorMsg) {
            //纯英文
            if (!/^[A-Za-z]+$/.test(value)) {

            }
        },
        onlyZh: function(value, errorMsg) {
            //纯中文
            if (!/^[\u4e00-\u9fa5]+$/.test(value)) {
                return errorMsg;
            }
        },
        onlyNum: function(value, errorMsg) {
            //数字包含小数
            if (!/^[0-9]+([.][0-9]+){0,1}$/.test(value)) {
                return errorMsg;
            }
        },
        onlyInt: function(value, errorMsg) {
            //整数
            if (!/^[0-9]*$/.test(value)) {
                return errorMsg;
            }
        },
        isChecked: function(value, errorMsg, el) {
            var i = 0;
            var $collection = $(el).find('input:checked');
            if(!$collection.length){
                return errorMsg;
            }
        },
        pwdChecked:function(value, errorMsg){
            //数字包含小数
            if (!/(?!^[0-9]+$)(?!^[A-z]+$)(?!^[^A-z0-9]+$)^.{6,20}$/.test(value)) {
                return errorMsg;
            }
        },
        romate: function(value,url,errorMsg) {
            //console.log(url);
            var arrUrl = url.split("?");
            var prefixUrl = arrUrl[0];
            var param = arrUrl[1];
            var dataInfo = param+value;
            $.ajax({
                type: "get",//使用get方法访问后台
                dataType: "json",//返回json格式的数据
                url: prefixUrl,//要访问的后台地址
                data:dataInfo,
                async:true,
                timeout:1000,
                complete :function(){},//AJAX请求完成时隐藏loading提示
                success: function(msg){//msg为返回的数据，在这里做数据绑定
                    errorMsg= msg;
                },
                error:function(xhr,status,error){
                    errorMsg =  "验证错误，请重新尝试！";
                }
            });
            if(errorMsg!="undefined"){
                return errorMsg;
            }
        }
    };
    /*************************Validator类*****************************/
    var setting = {
        type: null,
        onFocus: function() {
            this.parent().addClass('ak-valid_active');
            return false;
        },
        onBlur: function() {
            var $parent = this.parent();
            var _status = parseInt(this.attr('data-status'));
            $parent.removeClass('ak-valid_active');
            if (!_status) {
                $parent.addClass('ak-valid_error');
            }
            return false;
        },
        onChange: null,
        successTip: true
    };
    var Validator = function() {
        this.cache = [];
    };
    Validator.prototype.add = function(dom, rules) {
        var self = this;
        for (var i = 0, rule; rule = rules[i++];) {
            (function(rule) {
                var strategyAry = rule.strategy.split(':');
                var errorMsg = rule.errorMsg;
                self.cache.push(function() {
                    var strategy = strategyAry.shift(); // 前删匹配方式并赋值
                    strategyAry.unshift(dom.value); // 前插value值
                    strategyAry.push(errorMsg); // 后插出错提示
                    strategyAry.push(dom); // 后插dom
                    if (!RULES[strategy]) {
                        $.error('没有' + strategy + '规则，请检查命名或自行定义');
                    }
                    return {
                        errorMsg: RULES[strategy].apply(dom, strategyAry),
                        el: dom
                    };
                });
            }(rule));
        }
    };
    Validator.prototype.start = function() {
        var result;
        for (var i = 0, validatorFunc; validatorFunc = this.cache[i++];) {
            var result = validatorFunc();
            if (setting.successTip) {
                new Validator().showMsg($(result.el), '', 1);
            }
            if (result.errorMsg) {
                return result;
            }

        }
        return true;
    };
    Validator.prototype.showMsg = function(target, msg, status, callback) {
        //status
        // 0 : tip
        // 1 : success
        // 2 : error
        var _current = status ? (status > 1 ? 'ak-valid_error' : 'ak-valid_success') : 'tip';
        var $context = target.parent();
        var $msg = $context.find('.ak-valid_message');
        var _other = target.attr('data-type') || '';
        $msg.remove();
        $context.removeClass('ak-valid_success tip ak-valid_error').addClass(_current+' '+_other).append('<var class="ak-valid_message clear">' + msg + '</var>');
        $context.find("var").css({
            "margin-left": $context.find('.required').innerWidth() + 10,
            "line-height": $context.find('.required').outerHeight() + "px"
        })
    };
    var plugin = {
        init: function(options) {
            var $form = this;
            var $body = $('body');
            var $required = $form.find('.required');
            setting = $.extend(setting, options);
            if (setting.type) {
                $.extend(RULES, setting.type);
            }
            var validator = new Validator();
            $body.on({
                focus: function(event) {
                    var $this = $(this);
                    var _tipMsg = $this.attr('data-tip') || '';
                    var _status = $this.attr('data-status');
                    if (_status === undefined ||!parseInt(_status)) {
                        validator.showMsg($this, _tipMsg);
                    }
                    setting.onFocus ? setting.onFocus.call($this, arguments) : '';
                },
                blur: function(event) {
                    var $this = $(this);
                    var dataValid = $this.attr('data-valid');
                    var validLen = dataValid.split('||');
                    var errCollection = $this.attr('data-error');
                    var errMsgAry = errCollection.split("||");
                    var strategyAry, strategy, errMsg;

                    for (var i = 0; i < validLen.length; i++) {
                        strategyAry = validLen[i].split(':');
                        strategy = strategyAry.shift();
                        strategyAry.unshift(this.value);
                        strategyAry.push(errMsgAry[i]);
                        strategyAry.push(this);
                        errMsg = RULES[strategy].apply(this, strategyAry);
                        if (errMsg) {
                            $this.attr('data-status', 0);
                            validator.showMsg($this, errMsg, 2);
                            break;
                        }
                    }
                    if (!errMsg) {
                        $this.attr('data-status', 1);
                        setting.successTip ? validator.showMsg($this, '', 1) : $this.parent().find('.ak-valid_message').remove();
                    }
                    setting.onBlur ? setting.onBlur.call($this, arguments) : '';
                },
                change: function(event) {
                    setting.onChange ? setting.onChange.call($this, arguments) : '';
                }
            }, '.required');
        },
        submit_Validate: function(options) {
            var $form = options || this;
            var $body = $('body');
            var $required = $form.find('.required');
            var validator = new Validator();
            var $target;
            $.each($required, function(index, el) {
                var $el = $(el);
                var dataValid = $el.attr('data-valid') + "";
                var validLen = dataValid.split('||');
                var errCollection = $el.attr('data-error') + "";
                var errMsgAry = errCollection.split("||");
                var ruleAry = [];
                for (var i = 0; i < validLen.length; i++) {
                    ruleAry.push({
                        strategy: validLen[i],
                        errorMsg: errMsgAry[i]
                    });
                }
                validator.add(el, ruleAry);
            });
            var result = validator.start();
            if (result.errorMsg) {
                $target = $(result.el);
                //$target.attr('data-status', 0)[0].focus();
                validator.showMsg($target, result.errorMsg, 2);
                return false;
            }
            return true;
        }
    };
    $.fn.Andrew_Validate = function() {
        var method = arguments[0];
        if (plugin[method]) {
            method = plugin[method];
            arguments = Array.prototype.slice.call(arguments, 1);
        } else if (typeof(method) == 'object' || !method) {
            method = plugin.init;
        } else {
            $.error('Method ' + method + ' does not exist on jQuery.validate Plugin');
            return this;
        }
        return method.apply(this, arguments);
    }
}(jQuery));

/*-----------------------------------------------Andrew_PortraitCropbox-------------------------------------------*/
(function($){
    var Andrew_PortraitCropbox = function(options, el){
        var el = el || $(options.imageBox),
            obj =
                {
                    state : {},
                    ratio : 1,
                    options : options,
                    imageBox : el,
                    thumbBox : el.find(options.thumbBox),
                    rotator : el.find(options.rotator),
                    image : new Image(),
                    getDataURL: function ()
                    {
                        var width = this.thumbBox.width(),
                            height = this.thumbBox.height(),
                            canvas = document.createElement("canvas"),
                            dim = el.css('background-position').split(' '),
                            size = el.css('background-size').split(' '),
                            dx = parseInt(dim[0]) - el.width()/2 + width/2,
                            dy = parseInt(dim[1]) - el.height()/2 + height/2,
                            dw = parseInt(size[0]),
                            dh = parseInt(size[1]),
                            sh = parseInt(this.image.height),
                            sw = parseInt(this.image.width);

                        canvas.width = width;
                        canvas.height = height;
                        var context = canvas.getContext("2d");
                        context.drawImage(this.image, 0, 0, sw, sh, dx, dy, dw, dh);
                        var imageData = canvas.toDataURL('image/png');
                        return imageData;
                    },
                    getBlob: function()
                    {
                        var imageData = this.getDataURL();
                        var b64 = imageData.replace('data:image/png;base64,','');
                        var binary = atob(b64);
                        var array = [];
                        for (var i = 0; i < binary.length; i++) {
                            array.push(binary.charCodeAt(i));
                        }
                        return  new Blob([new Uint8Array(array)], {type: 'image/png'});
                    },
                    zoomIn: function ()
                    {
                        this.ratio*=1.1;
                        setBackground();
                    },
                    zoomOut: function ()
                    {
                        this.ratio*=0.9;
                        setBackground();
                    }
                },
            setBackground = function()
            {
                var w =  parseInt(obj.image.width)*obj.ratio;
                var h =  parseInt(obj.image.height)*obj.ratio;

                var pw = (el.width() - w) / 2;
                var ph = (el.height() - h) / 2;
                /*
                'background-size': w/3.18 +'px ' + h/3.18 + 'px',
                    'background-position': pw/1.75 + 'px ' + ph/1.75 + 'px',
                */
                el.css({
                    'background-image': 'url(' + obj.image.src + ')',
                    'background-size': w +'px ' + h + 'px',
                    'background-position': pw + 'px ' + ph + 'px',
                    'background-repeat': 'no-repeat'});
            },
            imgMouseDown = function(e)
            {
                e.stopImmediatePropagation();

                obj.state.dragable = true;
                obj.state.mouseX = e.clientX;
                obj.state.mouseY = e.clientY;
            },
            imgMouseMove = function(e)
            {
                e.stopImmediatePropagation();

                if (obj.state.dragable)
                {
                    var x = e.clientX - obj.state.mouseX;
                    var y = e.clientY - obj.state.mouseY;

                    var bg = el.css('background-position').split(' ');

                    var bgX = x + parseInt(bg[0]);
                    var bgY = y + parseInt(bg[1]);

                    el.css('background-position', bgX +'px ' + bgY + 'px');

                    obj.state.mouseX = e.clientX;
                    obj.state.mouseY = e.clientY;
                }
            },
            imgMouseUp = function(e)
            {
                e.stopImmediatePropagation();
                obj.state.dragable = false;
            },
            zoomImage = function(e)
            {
                e.originalEvent.wheelDelta > 0 || e.originalEvent.detail < 0 ? obj.ratio*=1.1 : obj.ratio*=0.9;
                setBackground();
            };

        obj.rotator.show();
        obj.image.onload = function() {
            obj.rotator.hide();
            setBackground();

            el.bind('mousedown', imgMouseDown);
            el.bind('mousemove', imgMouseMove);
            $(window).bind('mouseup', imgMouseUp);
            el.bind('mousewheel DOMMouseScroll', zoomImage);
        };
        obj.image.src = options.imgSrc;
        el.on('remove', function(){$(window).unbind('mouseup', imgMouseUp)});

        return obj;
    };

    jQuery.fn.Andrew_PortraitCropbox = function(options){
        return new Andrew_PortraitCropbox(options, this);
    };
}(jQuery));

/*-----------------------------------------------Andrew_DateTime-------------------------------------------*/
(function($){
    var jet = {},
        doc = document,
        regymdzz = "YYYY|MM|DD|hh|mm|ss|zz", gr = /\-/g,
        regymd = "YYYY|MM|DD|hh|mm|ss|zz".replace("|zz",""),
        parseInt = function (n) { return window.parseInt(n, 10);},
        config = {
            skinCell:"",
            language:{
                name  : "cn",
                month : ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"],
                weeks : [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ],
                times : ["Hour","Minute","Second"],
                titText: "Select Date",
                clear : "Clear",
                today : "Today",
                yes   : "Confirm",
                close : "Close"
            },
            range:false,
            trigger:"click",
            format:"YYYY-MM-DD hh:mm:ss", //日期格式
            minDate:"1900-01-01 00:00:00", //最小日期
            maxDate:"2099-12-31 23:59:59" //最大日期
        };
    $.fn.Andrew_DateTime = function(options){
        return new Andrew_DateTime($(this),options||{});
    };
    $.extend({
        Andrew_DateTime:function(elem, options){
            return new Andrew_DateTime($(elem),options||{});
        }
    });
    jet.isObj = function (obj){
        for(var i in obj){return true;}
        return false;
    };
    jet.reMatch = function (str) {
        return str.match(/\w+|d+/g);
    };
    jet.docScroll = function(type) {
        type = type ? "scrollLeft" :"scrollTop";
        return document.body[type] | document.documentElement[type];
    };
    jet.docArea = function(type) {
        return document.documentElement[type ? "clientWidth" :"clientHeight"];
    };
    //判断是否闰年
    jet.isLeap = function(y) {
        return (y % 100 !== 0 && y % 4 === 0) || (y % 400 === 0);
    };
    //补齐数位
    jet.digit = function(num) {
        return num < 10 ? "0" + (num | 0) :num;
    };
    //判断是否为数字
    jet.isNum = function(value){
        return /^[+-]?\d*\.?\d*$/.test(value) ? true : false;
    };
    //获取本月的总天数
    jet.getDaysNum = function(y, m) {
        var num = 31;
        switch (parseInt(m)) {
            case 2: num = jet.isLeap(y) ? 29 : 28; break;
            case 4: case 6: case 9: case 11: num = 30; break;
        }
        return num;
    };
    //获取月与年
    jet.getYM = function(y, m, n) {
        var nd = new Date(y, m - 1);
        nd.setMonth(m - 1 + n);
        return {
            y: nd.getFullYear(),
            m: nd.getMonth() + 1
        };
    };
    //获取上个月
    jet.prevMonth = function(y, m, n) {
        return jet.getYM(y, m, 0 - (n || 1));
    };
    //获取下个月
    jet.nextMonth = function(y, m, n) {
        return jet.getYM(y, m, n || 1);
    };
    //转换日期格式
    jet.parse = function(ymdhms, format) {
        return format.replace(new RegExp(regymdzz,"g"), function(str, index) {
            return str == "zz" ? "00":jet.digit(ymdhms[str]);
        });
    };
    jet.isparmat = function(format) {
        var remat = jet.reMatch(format), mat = regymdzz.split("|"), tmpArr = [];
        $.each(mat,function (m,mval) {
            $.each(remat,function (r,rval) {
                if (mval == rval) tmpArr.push(rval);
            });
        });
        return tmpArr.join("-");
    };

    jet.parseOld = function(ymd, hms, format) {
        ymd = ymd.concat(hms);
        var ymdObj = {}, mat = regymdzz.split("|"),
            remat = jet.reMatch(format);
        $.each(ymd,function (i,val) {
            ymdObj[remat[i]] = parseInt(val);
        });
        return format.replace(new RegExp(regymdzz,"g"), function(str, index) {
            return str == "zz" ? "00":jet.digit(ymdObj[str]);
        });
    };
    //验证日期格式
    jet.checkFormat = function(format) {
        var ymdhms = [];
        format.replace(new RegExp(regymdzz,"g"), function(str, index) {
            ymdhms.push(str);
        });
        return ymdhms.join("-");
    };
    jet.splMatch = function(str) {
        var timeArr = str.split(" ");
        return jet.reMatch(timeArr[0]);
    };
    jet.mlen = function (format) {
        var matlen = format.match(/\w+|d+/g).length,
            mathh = (format.substring(0, 2) == "hh"),
            lens = mathh&&matlen<=3 ? 7 : matlen;
        return lens;
    };
    //验证日期
    jet.checkDate = function (date) {
        var dateArr = jet.reMatch(date);
        if (isNaN(dateArr[0]) || isNaN(dateArr[1]) || isNaN(dateArr[2])) return false;
        if (dateArr[1] > 12 || dateArr[1] < 1) return false;
        if (dateArr[2] < 1 || dateArr[2] > 31) return false;
        if ((dateArr[1] == 4 || dateArr[1] == 6 || dateArr[1] == 9 || dateArr[1] == 11) && dateArr[2] > 30) return false;
        if (dateArr[1] == 2) {
            if (dateArr[2] > 29) return false;
            if ((dateArr[0] % 100 == 0 && dateArr[0] % 400 != 0 || dateArr[0] % 4 != 0) && dateArr[2] > 28) return false;
        }
        return true;
    };
    //返回日期
    function DateTime() {
        var ND = new Date(), that = this;
        //返回一个数值相同的新GetDateTime对象
        that.reDate = function () {
            return new DateTime();
        };
        //返回此实例的Date值
        that.GetValue = function () {
            return ND;
        };
        //获取此实例所表示日期的年份部分。
        that.GetFullYear = function () {
            return ND.getFullYear();
        };
        //获取此实例所表示日期的月份部分。
        that.GetMonth = function () {
            return ND.getMonth() + 1;
        };
        //获取此实例所表示日期的小时部分。
        that.GetHours = function () {
            return ND.getHours();
        };
        //获取此实例所表示的日期为该月中的第几天。
        that.GetDate = function () {
            return ND.getDate();
        };
        //获取此实例所表示日期的分钟部分。
        that.GetMinutes = function () {
            return ND.getMinutes();
        };
        //获取此实例所表示日期的秒部分。
        that.GetSeconds = function () {
            return ND.getSeconds();
        };
    }
    //获取返回的日期
    jet.GetDateTime = function (obj,format) {
        format = format || 'YYYY-MM-DD hh:mm:ss';
        var objVal = $.extend({YYYY:null,MM:null,DD:null,hh:0,mm:0,ss:0},obj),
            matArr = {YYYY:"FullYear",MM:"Month",DD:"Date",hh:"Hours",mm:"Minutes",ss:"Seconds"};

        var result = new DateTime().reDate();
        $.each(["ss","mm","hh","DD","MM","YYYY"],function (i,mat) {
            if (!jet.isNum(parseInt(objVal[mat]))) return null;
            var reVal = result.GetValue();
            if (parseInt(objVal[mat]) || parseInt(objVal[mat]) == 0){
                reVal["set"+matArr[mat]](result["Get"+matArr[mat]]() + (mat == "MM" ? -1 : 0) + parseInt(objVal[mat]));
            }
        });
        //获取格式化后的日期
        var reParse = jet.parse({
            YYYY:result.GetFullYear(), MM:result.GetMonth(), DD:result.GetDate(),
            hh:result.GetHours(), mm:result.GetMinutes(), ss:result.GetSeconds()
        }, format);
        return reParse;
    };

    //判断元素类型
    jet.isValHtml = function(elem) {
        return /textarea|input/.test(elem[0].tagName.toLocaleLowerCase());
    };
    jet.isBool = function(obj){  return (obj == undefined || obj == true ?  true : false); };
    var searandom = function (){
        var str = "",arr = [1,2,3,4,5,6,7,8,9,0];
        for(var i=0; i<8; i++) str += arr[Math.round(Math.random() * (arr.length-1))];
        return str;
    };
    function Andrew_DateTime(elem, opts){
        this.opts = opts;
        this.valCell = elem;
        this.format = this.opts.format;
        this.initdates();
    }
    var jedfn = Andrew_DateTime.prototype, jefix = "jefixed",matArr = jet.reMatch(regymdzz);
    jedfn.initdates = function(){
        var that = this, opts = that.opts, newDate = new Date(),
            jetrigger = opts.trigger != undefined ? opts.trigger : config.trigger,
            zIndex = opts.zIndex == undefined ? 10000 : opts.zIndex,
            isinitVal = (opts.isinitVal == undefined || opts.isinitVal == false) ? false : true;
        var randomCell = "#ak-DateTime"+searandom(),isShow = jet.isBool(opts.isShow);
        that.areaVal = [];
        opts.range = opts.range || config.range;
        that.fixed = jet.isBool(opts.fixed);
        var formatDate = function (cls,boxcell) {
            var input_that = $(that.valCell[0]);
            var dateDiv = $("<div/>",{"id":boxcell.replace(/\#/g,""),"class":"ak-DateTime" +(opts.skinCell || config.skinCell)}),
                reabsfix = !isShow ? "relative" : (that.fixed == true ? "absolute" :"fixed");
            dateDiv.css({"z-index": boxcell != "#ak-DateTime" ? "" : zIndex ,"position":reabsfix, "width": input_that.outerWidth()});
            if(boxcell != "#ak-DateTime") dateDiv.attr({"jeformat":opts.format || config.format,"jefixed":randomCell});
            var min = config.minDate.split(" "), max = config.maxDate.split(" ");
            jet.minDate = (!/\-/g.test(opts.minDate)&&opts.minDate!=undefined ? min[0]+" "+opts.minDate : opts.minDate) || config.minDate;
            jet.maxDate = (!/\-/g.test(opts.maxDate)&&opts.maxDate!=undefined ? max[0]+" "+opts.maxDate : opts.maxDate) || config.maxDate;
            jet.boxelem = !isShow ? boxcell : "#ak-DateTime";
            that.format = !isShow ? dateDiv.attr("jeformat") : (opts.format || config.format);
            var vals = that.getValue({});
            $(cls).append(dateDiv);
            that.renderHtml(vals[0].YYYY, vals[0].MM,vals[0].DD, opts,jet.boxelem);
        };
        //为开启初始化的时间设置值
        if (isinitVal && jetrigger) {
            //opts.range = undefined;
            var ndate = opts.initDate || [], reVal;
            if (ndate[1]){
                var addval = jet.reMatch(jet.GetDateTime(ndate[0]));
                reVal = [{YYYY:addval[0], MM:jet.digit(addval[1]), DD:jet.digit(addval[2]) , hh:jet.digit(addval[3]), mm:jet.digit(addval[4]), ss:jet.digit(addval[5]) }];
            }else {
                reVal = that.getValue(jet.isObj(ndate[0]) ? ndate[0] : {});
            }
            that.setValue(reVal[0],opts.format || config.format);
        }
        //判断固定元素是否存在
        if(!isShow){
            formatDate(that.valCell,randomCell);
        }else {
            //insTrigger的值为true时内部默认点击事件
            var jd = ["body","#ak-DateTime"];
            if (jetrigger) {
                /*that.valCell.on(jetrigger, function (ev) {
                    ev.stopPropagation();
                    if ($(jd[1]).length > 0) return;
                    formatDate(jd[0],jd[1]);
                });*/
                that.valCell.on(jetrigger, function (ev) {
                    ev.stopPropagation();
                    if ($(jd[1]).length > 0) return;
                    formatDate(jd[0],jd[1]);
                    $(jd[1]).slideDown();
                });
            }else {
                if ($(jd[1]).length > 0) return;
                formatDate(jd[0],jd[1]);
                //console.log(that);
                $(jd[1]).slideDown();
            }
        }
    };
    jedfn.parseFormat = function(ymdhms,format) {
        return jet.parse(ymdhms,format);
    };
    //转换日期值
    jedfn.parseValue = function (fnStr,matStr) {
        var that = this, valArr=[],opts = that.opts, setVal = "",elm = $(jet.boxelem),
            formats = matStr == undefined ? ($(elm.attr(jefix)).length > 0 ? elm.attr("jeformat") : that.format) : matStr,
            dateStr = $.isFunction(fnStr) ? fnStr() : fnStr;
        if (dateStr != "" || dateStr.length > 0 ){
            var unrange = opts.range != false,
                rangeArr = new Array(unrange ? 2 : 1);
            $.each(rangeArr,function (i) {
                var rangLen = rangeArr.length == 2,ymdObj = {},parmat = jet.reMatch(formats),
                    ranArr = rangLen ? dateStr.split(opts.range) : dateStr;
                if (rangLen){
                    $.each(jet.reMatch(ranArr[i]),function (r,val) {
                        ymdObj[jet.mlen(that.format) == 7 ? parmat[r] : matArr[r]] = val;
                    });
                }
                valArr.push(that.parseFormat((rangLen ? ymdObj : ranArr), formats));
                ymdObj = {};
            });
            setVal = valArr.join(unrange ? opts.range : "");
        }
        return setVal;
    };
    //设置日期值
    jedfn.setValue = function (fnStr,matStr,bool) {
        var that = this, elCell = that.valCell,strVal;
        if((typeof fnStr=='string')&&fnStr!=''&&that.opts.range == false){
            var reVal = jet.reMatch(fnStr), inObj={};
            $.each(jet.reMatch(that.format),function (r,val) {
                inObj[val] = parseInt(reVal[r]);
            });
            strVal = inObj;
        }else {
            strVal = fnStr;
        }
        var type = jet.isValHtml(elCell) ? "val" : "text",
            vals = that.parseValue(strVal,matStr);
        if (bool != false) elCell[type](vals);
        return vals;
    };
    //获取日期值
    jedfn.getValue = function (valobj) {
        var that = this, objCell = that.valCell,
            opts = that.opts, reObj, result = new DateTime().reDate(),
            dateY = result.GetFullYear(),dateM = result.GetMonth(),dateD = result.GetDate(),
            timeh = result.GetHours(),timem = result.GetMinutes(),times = result.GetSeconds();
        if (valobj == undefined && jet.isBool(opts.isShow)){
            var type = jet.isValHtml(objCell) ? "val" : "text";
            reObj = objCell[type]();
        }else {
            var isValShow = jet.isBool(opts.isShow) ? (that.getValue() == "") : !jet.isBool(opts.isShow),
                objarr = $.extend({YYYY:null,MM:null,DD:null},valobj||{}),
                ranMat = [],newArr = new Array(2),unObj = function (obj) {
                    return [(objarr[obj] == undefined || objarr[obj] == null),objarr[obj]]
                }, defObj = [{ YYYY:dateY,MM:dateM,DD:dateD, hh:timeh,mm:timem,ss:times,zz:00},
                    { YYYY:dateY,MM:dateM,DD:dateD, hh:timeh,mm:timem,ss:times,zz:00}];
            if (isValShow) {
                //目标为空值则获取当前日期时间
                $.each(newArr,function (i) {
                    var inObj = {};
                    $.each(matArr, function (r, val) {
                        inObj[val] = parseInt(unObj(val)[0] ? defObj[i][val] : unObj(val)[1]);
                    });
                    ranMat.push($.extend(defObj[i], inObj));
                });
            } else {
                var isunRange = opts.range != false, initVal = that.getValue(),
                    spVal = initVal.split(opts.range), reMat = jet.reMatch(that.format);
                $.each(newArr,function (i) {
                    var inObj = {}, reVal = isunRange ? jet.reMatch(spVal[i]) : jet.reMatch(initVal);
                    $.each(reMat,function (r,val) {
                        inObj[val] = parseInt(reVal[r]);
                    });
                    var exVal = $.extend(inObj,valobj||{});
                    ranMat.push($.extend(defObj[i],exVal));
                });
            }
            reObj = ranMat;
        }
        return reObj;
    };
    //布局控件骨架
    jedfn.renderHtml = function(ys, ms, ds, opts,boxcls){
        var that = this, boxCell = $(boxcls),
            lang = opts.language || config.language,
            isrange = opts.range != false,
            isShow = jet.isBool(opts.isShow);
        var minTime = jet.minDate.replace(/\s+/g," ").split(" "),
            maxTime = jet.maxDate.replace(/\s+/g," ").split(" "),
            allvals = that.getValue({YYYY:ys,MM:ms,DD:ds}),
            vals = allvals[0], valx = allvals[1];
        that.format = isShow ? that.format : boxCell.attr("jeformat");
        var mlens = jet.mlen(that.format), testhh = /\hh/.test(that.format);
        var clearTxt = lang.name == "cn" ? (!isShow ? "Reset":lang.clear):(!isShow ? "Reset":lang.clear);
        var headcon = "<div class='arthead bg_title'></div><div class='artcont'></div>",
            artcont = $("<div/>",{"class":"maincont"}),
            footer = $("<div/>",{"class":"mainfoot"}),
            daycon = $("<div/>",{"class":"daybox"}).append(headcon),
            ymscon = $("<div/>",{"class":"ymsbox"}).append(headcon),
            timecon = $("<div/>",{"class":"timebox"}).append(headcon);
        artcont.append(ymscon).append(daycon).append(mlens==1||mlens==2?"":timecon);
        boxCell.empty().append(artcont.children().hide()).append(footer);
        var timeStr = function () {
                var emStr = '<em></em><i>:</i><em></em><i>:</i><em></em>';
                return isrange ? emStr +"<span> ~ </span>"+ emStr : emStr;
            },
            btnStr = '<button class="clear bg_title">'+clearTxt+'</button><button class="today bg_title">'+lang.today+'</button><button class="setok bg_title">'+lang.yes+'</button>',
            timeDiv = $("<div/>",{"class":"timecon"}).append(timeStr()),
            btnsDiv = $("<div/>",{"class":"btnscon"}).append(btnStr);
        footer.append(timeDiv).append(btnsDiv);
        boxCell.append($("<div/>",{"class":"ak-DateTime-tips"}).hide());
        that.maincon = function (elem,is) { return boxCell.find(elem+" > "+(is == 0 ? ".arthead":".artcont")); };
        //设置时分秒
        if (testhh) {
            var minVal = /\s/.test(jet.minDate) ? minTime[1] : minTime[0],
                maxVal = /\s/.test(jet.maxDate) ? maxTime[1] : maxTime[0];
            var rehms = jet.reMatch(minVal), vehms = [vals.hh, vals.mm, vals.ss], hms = [];
            if (isrange) {
                if (that.getValue() == "") {
                    hms = mlens == 7 ? rehms.concat(rehms) : rehms.concat([00, 00, 00]);
                } else {
                    hms = vehms.concat([valx.hh, valx.mm, valx.ss]);
                }
            }else {
                hms = vehms;
            }
            $.each(footer.find(".timecon em"), function (i, cls) {
                $(this).text(jet.digit(hms[i]));
            });
        }else {
            footer.find(".timecon").hide();
        }
        //根据日期格式进行对应的日期时间显示
        if(mlens == 7){
            that.maincon(".timebox",0).html(lang.titText);
            boxCell.find(".timebox").show();
            that.eachHms(opts,boxCell);
        }else if(mlens>=3 && mlens<=6){
            that.maincon(".daybox",0).append('<button class="yearprev yprev bg_title"></button><button class="monthprev mprev bg_title"></button><button class="monthnext mnext bg_title"></button><button class="yearnext ynext bg_title"></button>');
            boxCell.find(".daybox").show();
            that.eachDays(vals.YYYY, vals.MM, vals.DD, opts, boxCell);
            //判断日期格式中是否包含hh（时）
            if(testhh){
                that.maincon(".timebox",1).attr("cont","no");
                that.maincon(".timebox",0).html(lang.titText+'<em class="bg_title close"></em>');
                boxCell.find(".timecon").on("click",function () {
                    if (that.maincon(".timebox",1).attr("cont") == "no"){
                        that.maincon(".timebox",1).attr("cont","yes");
                        boxCell.find(".ymsbox,.daybox").hide();
                        boxCell.find(".timebox").show();
                        that.eachHms(opts,boxCell);
                        that.dateOrien(boxCell, that.valCell);
                    }
                });
                that.maincon(".timebox",0).on("click",".close",function () {
                    that.maincon(".timebox",1).html("").attr("cont","no");
                    boxCell.find(".ymsbox,.timebox").hide();
                    boxCell.find(".daybox").show();
                    that.dateOrien(boxCell, that.valCell);
                });

                timeDiv.css({"cursor":"pointer"});
            }
            //将所有子元素用一个生成的div将所有段落包裹起来
            that.maincon(".ymsbox",0).append('<button class="yearprev yprev"></button><button class="yearnext ynext"></button><button class="close"></button>').addClass("ymfix");
            //将生成的年月插入到元素中
            that.eachYM(vals.YYYY, vals.MM, opts, boxCell,".fixcon");
        }
        //为年月的情况下执行
        if(mlens==1 || mlens==2){
            that.maincon(".ymsbox",0).append('<button class="yearprev yprev"></button><button class="yearnext ynext"></button>');
            boxCell.find(".ymsbox").show();
            that.eachYM(vals.YYYY, vals.MM, opts, boxCell,".ak-DateTime-cont");
        }
        //是否开启时间选择
        if(!jet.isBool(opts.isTime) || !isShow){
            footer.find(".timecon").hide();
        }
        if(!isShow) footer.find(".today").hide();
        //绑定各个事件
        that.eventsDate(opts,boxCell);
        setTimeout(function () {
            opts.success && opts.success(boxCell);
        }, 50);
    };
    jedfn.createYMHtml = function(ys, ms, opts){
        var year = parseInt(ys), month = parseInt(ms), headCls = this.maincon(".daybox",0);
        var ymCls = $("<p/>").css({"width":jet.isBool(opts.multiPane) ? '':'50%'}),
            ymText = "<span class='ymbtn'>"+month+"\u6708 "+year+"\u5e74</span>";
        headCls.append(ymCls.html(ymText));
        return year+"-"+month;
    };
    //循环生成年或月
    jedfn.eachYM = function(y, m,opts,boxCell,clsCell) {
        var that = this, yearArr = new Array(15), date = new Date(),
            lang = opts.language || config.language, ymscon = that.maincon(".ymsbox",1),
            multiPane = jet.isBool(opts.multiPane), mlens = jet.mlen(that.format),
            ymarr = that.getValue({}),testhh = /\hh/.test(that.format),
            formatYY = mlens == 1;

        if(ymscon.find(".ymcon").length > 0) ymscon.find(".ymcon").remove();
        $.each(new Array(multiPane ? 1 : 2),function (s) {
            var retSetCls = function (sym,gym,eym) {
                var sval = sym.replace(gr,""), gval = gym.replace(gr,""), eval = eym.replace(gr,"");
                if (/YYYY-MM-DD/g.test(jet.isparmat(that.format))){
                    return (parseInt(sval) == parseInt(gval)) ? (s == 0 ? "actdate bg_title" : "") : "";
                }else {
                    if (parseInt(sval) == parseInt(gval)) {
                        if (!testhh) {
                            that.areaVal.push(sym);
                            that.areaStart = true;
                        }
                        return "actdate bg_title";
                    } else if (parseInt(sval) > parseInt(gval) && parseInt(sval) < parseInt(eval)) {
                        return "contain";
                    } else if (parseInt(sval) == parseInt(eval)) {
                        if (!testhh) {
                            that.areaVal.push(sym);
                            that.areaStart = true;
                        }
                        return "actdate bg_title";
                    } else {
                        return "";
                    }
                }
            };
            var ymDiv = $("<div/>",{"class":"ymcon"}).addClass(s==1 ? "spaer":""),ymArr=[];
            $.each(formatYY ? yearArr : lang.month, function (n, val) {
                var ym = s==1 ? y + (formatYY ? yearArr.length : 1) : y,seCls;
                n = s==1 ? (formatYY ? 15+n : 12+n) : n;
                if (formatYY) {
                    var minArr = jet.splMatch(jet.minDate), maxArr = jet.splMatch(jet.maxDate),
                        minY = minArr[0], maxY = maxArr[0], year = (ym - 7 + n),
                        getyear = (that.getValue() == "" && jet.isBool(opts.isShow)) ? date.getFullYear() : that.getValue();
                    //判断是否在有效期内
                    if (year < minY || year > maxY) {
                        ymArr.push({style:"disabled",ym: year,idx:n});
                    } else {
                        seCls = retSetCls(year.toString(),getyear.toString(),ymarr[1].YYYY.toString());
                        ymArr.push({style:seCls,ym: year,idx:n});
                    }
                } else {
                    var minArr = jet.splMatch(jet.minDate), maxArr = jet.splMatch(jet.maxDate),
                        thisDate = parseInt(ym+""+jet.digit(val)+""+"01"),
                        minTime = parseInt(minArr[0]+""+jet.digit(minArr[1])+""+jet.digit(minArr[2])),
                        maxTime = parseInt(maxArr[0]+""+jet.digit(maxArr[1])+""+jet.digit(maxArr[2]));
                    //判断是否在有效期内
                    if (thisDate < minTime || thisDate > maxTime) {
                        ymArr.push({style:"disabled",ym: ym + "-" + jet.digit(val),idx:n});
                    } else {
                        var ymVal = ym + "-" + jet.digit(val),ymmVal = ymarr[0].YYYY+ "-" + jet.digit(ymarr[0].MM);
                        seCls = retSetCls(ymVal,ymmVal,(ymarr[1].YYYY+ "-" + jet.digit(ymarr[1].MM)));
                        ymArr.push({style:seCls,ym: ym + "-" + jet.digit(val),idx:n});
                    }
                }

            });
            var table = $('<table/>',{"class":formatYY ?"yul":"ymul"});
            //生成表格主体
            $.each(new Array(formatYY ? 5:4), function(i){
                var tr = $('<tr/>');
                $.each(new Array(3), function(){
                    var td = $("<td/>");
                    table.append(tr.append(td));
                })
            });
            //为表格赋值年月
            $.each(ymArr,function (i,val) {
                table.find("td").eq(i).addClass(val.style).attr({idx:val.idx,"je-val":val.ym}).html(val.ym)
            });
            ymscon.append(ymDiv.append(table));

        });
        var contd = ymscon.find("td"),ymstit = that.maincon(".ymsbox",0),
            eqNum = formatYY ? (multiPane ? 15-1:15*2-1):(multiPane ? 12-1:12*2-1),
            sval = contd.eq(0).text(), eval = contd.eq(eqNum).text();
        var mnx = [(formatYY ? sval:sval.substring(0,4)),(formatYY ? eval:eval.substring(0,4))];
        ymstit.find("p").remove();
        ymstit.append("<p>"+sval+" ~ "+eval+"</p>").attr({min:mnx[0],max:mnx[1]});
    };
    //初始验证正则
    jedfn.dateRegExp = function(valArr) {
        var enval = valArr.split(",")||[], re = "";
        var doExp = function (val) {
            var arr, tmpEval, re = /#?\{(.*?)\}/;
            val = val + "";
            while ((arr = re.exec(val)) != null) {
                arr.lastIndex = arr.index + arr[1].length + arr[0].length - arr[1].length - 1;
                tmpEval = parseInt(eval(arr[1]));
                if (tmpEval < 0) tmpEval = "9700" + -tmpEval;
                val = val.substring(0, arr.index) + tmpEval + val.substring(arr.lastIndex + 1);
            }
            return val;
        };
        if (enval && enval.length > 0) {
            for (var i = 0; i < enval.length; i++) {
                re += doExp(enval[i]);
                if (i != enval.length - 1) re += "|";
            }
            re = re ? new RegExp("(?:" + re + ")") : null;
        } else {
            re = null;
        }
        //re = new RegExp((re + "").replace(/^\/\(\?:(.*)\)\/.*/, "$1"));
        return re;
    };
    //循环生成日
    jedfn.eachDays = function(ys, ms,ds, opts, boxCell){
        var that = this, isShow = jet.isBool(opts.isShow);
        var year = parseInt(ys), month = parseInt(ms), objCell = that.valCell,
            lang = opts.language || config.language, endval = opts.valiDate||[],
            minArr = jet.reMatch(jet.minDate), minNum = parseInt(minArr[0]+""+jet.digit(minArr[1])+""+jet.digit(minArr[2])),
            maxArr = jet.reMatch(jet.maxDate), maxNum = parseInt(maxArr[0]+""+jet.digit(maxArr[1])+""+jet.digit(maxArr[2]));
        var multiPane = jet.isBool(opts.multiPane),  ymdarr = that.getValue(!isShow ? {YYYY:ys,MM:ms,DD:ds}:{}),
            valrange = ((objCell.val() || objCell.text()) != "") && opts.range != false,
            ymdDate = parseInt(ymdarr[0].YYYY+""+jet.digit(ymdarr[0].MM)+""+jet.digit(ymdarr[0].DD));
        //设置时间标注
        var setMark = function (my, mm, md) {
            var Marks = opts.marks, contains = function(arr, obj) {
                var len = arr.length;
                while (len--) {
                    if (arr[len] === obj) return true;
                }
                return false;
            };
            return $.isArray(Marks) && Marks.length > 0 && contains(Marks, my + "-" + jet.digit(mm) + "-" + jet.digit(md)) ? '<i class="marks"></i>' :"";
        };
        //是否显示节日
        var isfestival = function(y, m ,d) {
            var festivalStr;
            if(opts.festival == true && lang.name == "cn"){
                var lunar = that.jeLunar(y, m - 1, d), feslunar = (lunar.solarFestival || lunar.lunarFestival),
                    lunartext = (feslunar && lunar.jieqi) != "" ? feslunar : (lunar.jieqi || lunar.showInLunar);
                festivalStr = '<p><span class="solar">' + d + '</span><span class="lunar">' + lunartext + '</span></p>';
            }else{
                festivalStr = '<p class="nolunar">' + d + '</p>';
            }
            return festivalStr;
        };
        //判断是否在限制的日期之中
        var dateLimit = function(Y, M, D, isMonth){
            var thatNum = parseInt(Y + "" + jet.digit(M) + "" + jet.digit(D));
            if(isMonth){
                if (thatNum >= minNum && thatNum <= maxNum) return true;
            }else {
                if (minNum > thatNum || maxNum < thatNum) return true;
            }
        };

        var eachDays = function (yd,md) {
            var count = 0, daysArr = [],
                firstWeek = new Date(yd, md - 1, 1).getDay() || 7,
                daysNum = jet.getDaysNum(yd, md), didx = 0,
                prevM = jet.prevMonth(yd, md),
                prevDaysNum = jet.getDaysNum(yd, prevM.m),
                nextM = jet.nextMonth(yd, md);
            //上一月剩余天数
            for (var p = prevDaysNum - firstWeek + 1; p <= prevDaysNum; p++, count++) {
                var pmark = setMark(prevM.y,prevM.m,p);
                var cls = dateLimit(prevM.y, prevM.m, p, false) ? "disabled" : "other";
                daysArr.push({style:cls,ymd:prevM.y+'-'+prevM.m+'-'+p,day:p,d:(isfestival(prevM.y,prevM.m,p) + pmark),idx:didx++});
            }
            //本月的天数
            for(var b = 1; b <= daysNum; b++, count++){
                var bmark = setMark(yd,md,b), cls = "";
                var dateval = parseInt(yd+""+jet.digit(md)+""+jet.digit(b)),
                    rangval = parseInt(ymdarr[1].YYYY+""+jet.digit(ymdarr[1].MM)+""+jet.digit(ymdarr[1].DD)),
                    parsdate = dateval > ymdDate, rangdate = dateval < rangval;
                if(dateLimit(yd, md, b, true)){
                    if(dateval == ymdDate){
                        cls = "actdate bg_title";
                        that.areaVal.push(yd+'-'+jet.digit(md)+'-'+jet.digit(b));
                        that.areaStart = true;
                    }else if(parsdate&&rangdate&&valrange){
                        cls = "contain";
                    }else if((dateval == rangval)&&valrange){
                        cls = "actdate bg_title";
                        that.areaVal.push(yd+'-'+jet.digit(md)+'-'+jet.digit(b));
                        that.areaEnd = true;
                    }else {
                        cls = "";
                    }
                }else {
                    cls = "disabled";
                }
                daysArr.push({style:cls,ymd:yd+'-'+md+'-'+b,day:b,d:(isfestival(yd,md,b) + bmark),idx:didx++});
            }
            //下一月开始天数
            for(var n = 1, nlen = 42 - count; n <= nlen; n++){
                var nmark = setMark(nextM.y,nextM.m,n);
                var cls = dateLimit(nextM.y, nextM.m, n, false) ? "disabled" : "other";
                daysArr.push({style:cls,ymd:nextM.y+'-'+nextM.m+'-'+n,day:n,d:(isfestival(nextM.y,nextM.m,n) + nmark),idx:didx++});
            }
            //将星期与日期拼接起来
            return daysArr;
        };
        var valdigit = function (val) {
            var spval = jet.reMatch(val) , rearr = [];
            $.each(spval,function (i,v) {
                rearr.push(jet.digit(v));
            });
            return rearr.join("-");
        };
        var moreArr = new Array(multiPane ? 1 : 2), isDec = (month + 1 > 12),ymarr = [];
        $.each(moreArr,function (d,val) {
            var table = $('<table/>',{"class":"daysul"}) ,thead = $('<thead/>'),
                tbody = $('<tbody/>'), t= d == 1 ? 42:0;
            table.append(thead).append(tbody);
            //生成表格主体
            $.each(new Array(7), function(i){
                var tr = $('<tr/>');
                $.each(new Array(7), function(){
                    var th = $("<th/>"), td = $("<td/>");
                    tr.append(i == 0 ? th : td.attr("idx",t++));
                    i == 0 ? thead.append(tr) : tbody.append(tr);
                })
            });
            var nian = (isDec && d == 1) ? year+1 : year,
                yue = (isDec && d == 1) ? 1 : (d == 1 ? month+1 : month);
            var arrDay = eachDays(nian,yue);
            var moreCls = $("<div/>",{'class':'contlist'});
            //赋值星期
            $.each(lang.weeks,function (i,val) {
                table.find("th").eq(i).text(val);
            });
            ymarr.push(that.createYMHtml(nian,yue, opts));
            $.each(arrDay,function (i,val) {
                var clsVal = val.style;
                if(endval.length > 0 && endval[0]!=""){
                    if(/\%/g.test(endval[0])){
                        var reval = endval[0].replace(/\%/g,"").split(","), enArr = [];
                        $.each(reval,function (r,rel) {
                            enArr.push(jet.digit(parseInt(rel)));
                        });
                        var isfind = $.inArray(jet.digit(val.day), enArr) == -1;
                        clsVal = jet.isBool(endval[1]) ? (isfind ? "disabled" :clsVal) : (isfind ? clsVal :"disabled");
                    }else {
                        var valreg = that.dateRegExp(endval[0]), regday = valreg.test(jet.digit(val.day));
                        clsVal = jet.isBool(endval[1]) ? (regday ? "disabled" : val.style) : (regday ? val.style : "disabled")
                    }
                }
                table.find("td").eq(i).addClass(clsVal).attr("je-val",valdigit(val.ymd)).html(val.d);
            });
            that.maincon(".daybox",1).append(moreCls.append(table)).addClass(d == 1 ? "spaer" : "");
        });
        that.maincon(".daybox",0).attr("je-ym",ymarr.join(","));
    };
    //循环生成时分秒
    jedfn.eachHms = function(opts,boxCell) {
        var that = this, lang = opts.language || config.language,
            multiPane = jet.isBool(opts.multiPane),
            gval = that.getValue({}), isVal = that.getValue() == "",
            ranges = opts.range == false,
            minTime = jet.minDate.replace(/\s+/g," ").split(" "),
            maxTime = jet.maxDate.replace(/\s+/g," ").split(" "),
            isymdh = /YYYY-MM-DD/g.test(jet.isparmat(that.format)) && /\hh/.test(that.format);
        var minhms = jet.reMatch(minTime[1]),
            maxhms = jet.reMatch(maxTime[1]);
        var hmsCell = that.maincon(".timebox",1),
            clas = ["action bg_title","disabled"],inputs = boxCell.find(".mainfoot .timecon em");
        //conhms = isymdh ? hmsCell.parent() : hmsCell;
        var date = new Date(), timeh = date.getHours(),
            timem = date.getMinutes(),times = date.getSeconds();
        var minVal = [gval[0].hh||timeh,gval[0].mm||timem,gval[0].ss||times],
            maxVal = [gval[1].hh||timeh,gval[1].mm||timem,gval[1].ss||times];
        if (opts.range == false && boxCell.find(".timelist").length > 0) return;
            $.each(new Array(ranges?1:2),function(m){
                var timeList=$("<div/>",{"class":"timelist"}).css({"width":ranges?"100%":"50%","float":ranges?"none":"left"});
                var timeDiv=$("<div/>",{"class":"contime"});
                var textDiv=$("<div/>",{"class":"textbox"});
                var timetxt=textDiv.append("<p>"+lang.times[0]+"</p><p>"+lang.times[1]+"</p><p>"+lang.times[2]+"</p>");
                timeList.append(timetxt);
            hmsCell.addClass(m==1 ? "spaer":"");
            $.each([24, 60, 60],function (i,lens) {
                var hmsCls = "",tuls = $("<ul/>").attr("idx",m==1 ? 3+i : i),
                    textem = inputs.eq(i).text();
                for (var h = 0; h < lens; h++) {
                    var tlis = $("<li/>");
                    //判断限制时间范围的状态
                    if (opts.range != false){
                        if (isymdh){
                            if (m==0){
                                if (h >= minhms[i]) {
                                    hmsCls = h == (isVal ? minhms[i]:minVal[i]) ? clas[0] : "";
                                } else{
                                    hmsCls = clas[1];
                                }
                            }else {
                                if (h > maxhms[i]) {
                                    hmsCls = clas[1];
                                }else {
                                    hmsCls = h == (isVal ? 0:maxVal[i]) ? clas[0] : "";
                                }
                            }
                        }else {
                            if (h >= minhms[i]) {
                                hmsCls = h == (isVal ? minhms[i]:(m==0?minVal[i]:maxVal[i])) ? clas[0] : "";
                            } else{
                                hmsCls = clas[1];
                            }
                        }
                    }else{
                        if (h >= minhms[i] && h <= maxhms[i]){
                            if (textem < minhms[i]){
                                hmsCls = h == minhms[i] ? clas[0] : "";
                            }else if (textem > maxhms[i]){
                                hmsCls = h == maxhms[i] ? clas[0] : "";
                            }else {
                                hmsCls = h == textem ? clas[0] : "";
                            }
                        }else {
                            hmsCls = clas[1];
                        }
                    }
                    tlis.text(jet.digit(h)).addClass(hmsCls);
                    hmsCell.append(timeList.append(timeDiv.append(tuls.append(tlis))));
                }
            });
            if (multiPane==false && ranges){
                timeList.css({"padding-left":timeList.outerWidth()/2+12,"padding-right":timeList.outerWidth()/2+12})
            }
        });
        //计算当前时分秒的位置
        that.locateScroll(hmsCell.find("ul"));
        //时分秒选择
        that.clickTime(opts,boxCell);
        var hmsTxt = [];
        $.each(minhms,function (i,val) {
            if (parseInt(val) > parseInt(maxhms[i])){
                hmsTxt.push("Not greater than the maximum "+lang.times[i]);
            }
        });
        if (hmsTxt.length > 0) that.tips(hmsTxt.join("<br/>"),4.5);
    };
    //为日期绑定各类事件
    jedfn.eventsDate = function(opts,boxCell) {
        var that = this, multiPane = jet.isBool(opts.multiPane);
        //上下月事件
        that.clickYM(opts,boxCell);
        //点击天事件
        that.clickDays(opts,boxCell);
        //按钮事件
        that.clickBtn(opts,boxCell);
        //自适应定位,值在isShow为true的情况下有效
        if(jet.isBool(opts.isShow)){
            var datepos = opts.position||[];
            if (datepos.length > 0){
                boxCell.css({"top":datepos[0],"left":datepos[1]});
            }else {
                that.dateOrien(boxCell, that.valCell);
                $(window).on("resize", function(){
                    that.dateOrien(boxCell, that.valCell);
                })
            }
        }
        //点击空白处隐藏
        $(document).on("mouseup", function(ev) {
            ev.stopPropagation();
            if (jet.boxelem == "#ak-DateTime"){
                var box = $(jet.boxelem);
                if (box.length > 0) {
                    $(jet.boxelem).slideUp();
                    setTimeout(function() {
                            that.dateClose();
                        },
                        500);
                }
                /*if (box && box.css("display") !== "none")  that.dateClose();*/
                if($("#ak-DateTime_tipscon").length > 0) $("#ak-DateTime_tipscon").remove();
                delete that.areaStart;
                delete that.areaEnd;
                that.areaVal = [];
            }
        });
        $(jet.boxelem).on("mouseup", function(ev) {
            ev.stopPropagation();
        });
    };
    //切换年月并重新生成日历
    jedfn.clickYM = function (opts,boxCell) {
        var that = this, ymhead = that.maincon(".ymsbox",0),elemCell = that.valCell,
            yPre = ymhead.find(".yprev"),
            yNext = ymhead.find(".ynext"),
            ymdhead = that.maincon(".daybox",0),
            isShow = jet.isBool(opts.isShow),
            ydPre = ymdhead.find(".yprev"),
            ydNext = ymdhead.find(".ynext"),
            mdPre = ymdhead.find(".mprev"),
            mdNext = ymdhead.find(".mnext"),
            mlens = jet.mlen(that.format),
            isYYMM = mlens == 2,
            isYY = mlens == 1;
        var carr = ["actdate","contain"],
            ymDate = new Date();
        var clickYmSelected = function () {
            var ulCell = that.maincon(".ymsbox",1).find(".ymcon"), tdCell = ulCell.find("td");
            tdCell.on("click",function () {
                var lithis = $(this), thisdate = lithis.attr("je-val");
                if (lithis.hasClass("disabled")) return;
                if(opts.range == false){
                    tdCell.removeClass(carr[0]);
                    lithis.addClass(carr[0]);
                    that.maincon(".ymsbox",0).attr("data-val",lithis.text());
                }else {
                    //判断是否存在选择的开始与结束日期
                    if (that.areaStart && that.areaEnd == undefined){
                        lithis.addClass(carr[0]);
                        that.areaEnd = true;
                        //添加当前选中的到数组中
                        that.areaVal.push(thisdate);
                        //遍历元素，并在范围中查找同时着色
                        tdCell.each(function () {
                            var sefl = $(this),seVals = sefl.attr("je-val").replace(gr,""),
                                rearea = [that.areaVal[0].replace(gr,""),that.areaVal[1].replace(gr,"")],
                                minVal = Math.min.apply(null, rearea), maxVal = Math.max.apply(null, rearea);
                            if (!sefl.hasClass("other")){
                                var contrast = parseInt(seVals) > parseInt(minVal) && parseInt(seVals) < parseInt(maxVal);
                                if(contrast){
                                    sefl.addClass(carr[1]);
                                }
                            }
                        });
                    }else if (that.areaStart && that.areaEnd){
                        //如果已经选择了一个范围，就清除属性
                        that.delAreaAttr();
                        tdCell.removeClass(carr[0]).removeClass(carr[1]);
                        lithis.addClass(carr[0]);
                        that.areaVal.push(thisdate);
                        that.areaStart = true;
                    }

                }
            });
        };
        if(isYYMM || isYY){
            clickYmSelected();
            //年或年月情况下的变化
            $.each([yPre, yNext], function (ym, cls) {
                cls.on("click", function (ev) {
                    var cthat = $(this), ymMonth = ymDate.getMonth()+1,
                        ymMin = parseInt(cthat.parent().attr("min")), ymMax = parseInt(cthat.parent().attr("max"));
                    var ymYear =isYY ? (ym == 0 ? ymMin : ymMax) : (ym == 0 ? --ymMin : ++ymMax);
                    that.renderHtml(ymYear, ymMonth, null, opts, boxCell);
                    if (opts.range == false) {
                        var ymobj = isYY ? {YYYY: ymYear} : {YYYY: ymYear, MM: ymMonth};
                        var value = that.parseValue(ymobj),
                            date = {
                                YYYY: ymYear, MM: ymMonth, DD: ymDate.getDate(),
                                hh: ymDate.getHours(), mm: ymDate.getMinutes(), ss: ymDate.getSeconds()
                            };
                        if ($.isFunction(opts.toggle)) opts.toggle(elemCell,value,date);
                    }
                })
            })
        }else {
            //切换年
            $.each([ydPre, ydNext], function (y, cls) {
                cls.on("click", function (ev) {
                    ev.stopPropagation();
                    var gym = jet.reMatch($(this).parent().attr("je-ym"));
                    var year = parseInt(gym[0]), month = parseInt(gym[1]),
                        pnYear = y == 0 ? --year : ++year;
                    that.renderHtml(pnYear, month, null, opts, boxCell);
                    if (opts.range == false) {
                        var gv = that.getValue({})[0];
                        var value = that.parseValue({YYYY: pnYear, MM: month, DD: gv.DD}),
                            dateobj = {
                                YYYY: pnYear, MM: month, DD: ymDate.getDate(),
                                hh: ymDate.getHours(), mm: ymDate.getMinutes(), ss: ymDate.getSeconds()
                            };
                        if ($.isFunction(opts.toggle)) opts.toggle({elem:elemCell,val:value,date:dateobj});
                    }
                });
            });
            //切换月
            $.each([mdPre, mdNext], function (m, cls) {
                cls.on("click", function (ev) {
                    ev.stopPropagation();
                    var gym = jet.reMatch($(this).parent().attr("je-ym"));
                    var year = parseInt(gym[0]), month = parseInt(gym[1]),
                        PrevYM = jet.prevMonth(year, month), NextYM = jet.nextMonth(year, month);
                    m == 0 ? that.renderHtml(PrevYM.y, PrevYM.m, null, opts, boxCell) : that.renderHtml(NextYM.y, NextYM.m, null, opts, boxCell);
                    var yearVal = m == 0 ? PrevYM.y : NextYM.y, monthVal = m == 0 ? PrevYM.m : NextYM.m;
                    if (opts.range == false) {
                        var gv = that.getValue({})[0];
                        var value = that.parseValue({YYYY: yearVal, MM: monthVal, DD: gv.DD}),
                            dateobj = {
                                YYYY: yearVal, MM: monthVal, DD: ymDate.getDate(),
                                hh: ymDate.getHours(), mm: ymDate.getMinutes(), ss: ymDate.getSeconds()
                            };
                        if ($.isFunction(opts.toggle)) opts.toggle({elem:elemCell,val:value,date:dateobj});
                    }
                    //console.log("jinru"+ymDate)
                });
            });
        }
        if(mlens >= 3 && mlens <= 6){
            that.maincon(".daybox",0).on("click",".ymbtn", function (ev) {
                boxCell.children(".ymsbox").show();
                boxCell.children(".daybox,.mainfoot").hide();
                if (isShow) that.dateOrien(boxCell, that.valCell);
            });
            var aloneSelym = function () {
                var ulCell = boxCell.find(".ymcon"), tdCell = ulCell.find("td");
                tdCell.on("click",function () {
                    var sefl = $(this), seval = jet.reMatch(sefl.attr("je-val"));
                    tdCell.removeClass(carr[0]);
                    sefl.addClass(carr[0]);
                    boxCell.children(".ak-DateTime-contfix").show();
                    boxCell.children(".ak-DateTime-ak-DateTimewrap").hide();
                    that.renderHtml(seval[0], seval[1],null, opts,boxCell);
                })
            };
            $.each([yPre, yNext], function (ym, cls) {
                cls.on("click", function (ev) {
                    var ymMonth = ymDate.getMonth()+1,
                        ymMin = parseInt($(this).parent().attr("min")), ymMax = parseInt($(this).parent().attr("max"));
                    var ymYear =isYY ? (ym == 0 ? ymMin : ymMax) : (ym == 0 ? --ymMin : ++ymMax);
                    that.eachYM(ymYear, ymMonth, opts, boxCell,".ak-DateTime-contfix");
                    aloneSelym();
                    if (isShow) that.dateOrien(boxCell, that.valCell);
                    if ($.isFunction(opts.toggle)) opts.toggle();
                })
            });
            ymhead.on("click",".close", function (ev) {
                boxCell.children(".daybox,.mainfoot").show();
                boxCell.children(".ymsbox").hide();
                if (isShow) that.dateOrien(boxCell, that.valCell);
            });
            aloneSelym();
        }

    };
    jedfn.gethmsVal = function(boxCell) {
        var hmsArr = {};
        boxCell.find(".timecon em").each(function(i) {
            var disb = $(this).attr('disabled');
            if(disb == undefined) hmsArr[matArr[3+i]] = $(this).text();
        });
        return hmsArr;
    };
    //绑定天的事件
    jedfn.clickDays = function (opts,boxCell) {
        var that = this, elemCell = that.valCell,valStr = "je-val",
            ulCls = boxCell.find(".daysul"), tdCls = ulCls.find("td"),
            lang = opts.language || config.language,
            carr = ["actdate bg_title","contain"];

        //点击绑定日期事件
        tdCls.on("click", function(ev) {
            var lithis = $(this), thisdate = lithis.attr(valStr),
                ymdArr = jet.reMatch(thisdate), dayArr = [];
            if (lithis.hasClass("disabled")) return;
            ev.stopPropagation();
            //单独选择
            var aloneSelected = function () {
                $.each(ymdArr,function (i,val) {
                    dayArr.push(parseInt(val));
                });
                if($(boxCell.attr(jefix)).length > 0 ){
                    that.renderHtml(dayArr[0], dayArr[1],dayArr[2], opts,boxCell);
                }else {
                    //判断是否为点击后关闭弹层
                    if(jet.isBool(opts.onClose)){
                        tdCls.removeClass(carr[0]);
                        lithis.addClass(carr[0]);
                    }else {
                        var ymdObj = {}, spval = jet.reMatch(lithis.attr(valStr));
                        //获取时分秒的集合
                        $.each(spval,function (i,val) {
                            ymdObj[matArr[i]] = val;
                        });
                        var objs = /\hh/.test(that.format) ? $.extend(ymdObj,that.gethmsVal(boxCell)) : ymdObj;
                        var vals = that.setValue(objs);
                        var box = $(jet.boxelem);
                        if (box.length > 0) {
                            $(jet.boxelem).slideUp();
                            setTimeout(function() {
                                    that.dateClose();
                                },
                                500);
                        }
                        if ($.isFunction(opts.okfun) || opts.okfun != null){
                            opts.okfun && opts.okfun({elem:elemCell,val:vals,date:objs});
                        }
                    }
                }
            };
            //区域选择
            var areaSelected = function () {
                //判断是否只选中一个
                if (that.areaStart && that.areaEnd == undefined){
                    lithis.addClass(carr[0]);
                    that.areaEnd = true;
                    //添加当前选中的到数组中
                    that.areaVal.push(thisdate);
                    //遍历元素，并在范围中查找同时着色
                    tdCls.each(function () {
                        var sefl = $(this),seVals = sefl.attr("je-val").replace(gr,""),
                            rearea = [that.areaVal[0].replace(gr,""),that.areaVal[1].replace(gr,"")],
                            minVal = Math.min.apply(null, rearea), maxVal = Math.max.apply(null, rearea);
                        if (!sefl.hasClass("other") && !sefl.hasClass("disabled")){
                            var contrast = parseInt(seVals) > parseInt(minVal) && parseInt(seVals) < parseInt(maxVal);
                            if(contrast){
                                sefl.addClass(carr[1]);
                            }
                        }
                    });
                }else if (that.areaStart && that.areaEnd){
                    //如果已经选择了一个范围，就清除属性
                    that.delAreaAttr();
                    tdCls.removeClass(carr[0]).removeClass(carr[1]);
                    lithis.addClass(carr[0]);
                    that.areaVal.push(thisdate);
                    that.areaStart = true;
                }
            };
            //判断是否要进行日期区域选择
            opts.range == false ? aloneSelected() : areaSelected();
        });
        if(opts.festival && lang.name == "cn") {
            boxCell.addClass("grid");
            //鼠标进入提示框出现
            tdCls.on("mouseover", function () {
                if($("#ak-DateTime_tipscon").length > 0) $("#ak-DateTime_tipscon").remove();
                var _this = $(this), atlunar = jet.reMatch(_this.attr(valStr)),
                    tipDiv = $("<div/>",{"id":"ak-DateTime_tipscon","class":"ak-DateTime_tipscon"}),
                    lunar = that.jeLunar(parseInt(atlunar[0]), parseInt(atlunar[1]) - 1, parseInt(atlunar[2]));
                var tiphtml = '<p>' + lunar.solarYear + '\u5E74' + lunar.solarMonth + '\u6708' + lunar.solarDate + '\u65E5 ' + lunar.inWeekDays + '</p><p class="c_red">\u519C\u5386：' + lunar.shengxiao + '\u5E74 ' + lunar.lnongMonth + '\u6708' + lunar.lnongDate + '</p><p>' + lunar.ganzhiYear + '\u5E74 ' + lunar.ganzhiMonth + '\u6708 ' + lunar.ganzhiDate + '\u65E5</p>';
                var Fesjieri = (lunar.solarFestival || lunar.lunarFestival) != "" ? '<p class="c_red">' + ("\u8282\u65E5："+lunar.solarFestival + lunar.lunarFestival) + '</p>' : "";
                var Fesjieqi = lunar.jieqi != "" ? '<p class="c_red">'+(lunar.jieqi != "" ? "\u8282\u6C14："+lunar.jieqi : "") + '</p>': "";
                var tiptext = (lunar.solarFestival || lunar.lunarFestival || lunar.jieqi) != "" ? (Fesjieri + Fesjieqi) : "";
                //生成提示框到文档中
                $("body").append(tipDiv);
                tipDiv.html(tiphtml + tiptext);
                //获取并设置农历提示框出现的位置
                var tipPos = jedfn.lunarOrien(tipDiv, _this);
                tipDiv.css({"z-index":  (opts.zIndex == undefined ? 10000 + 5 : opts.zIndex + 5),top:tipPos.top,left:tipPos.left,position:"absolute",display:"block"});
            }).on( "mouseout", function () { //鼠标移除提示框消失
                $("#ak-DateTime_tipscon").remove();
            });
        }
    };
    jedfn.clickBtn = function (opts,boxCell) {
        var that = this, elemCell = that.valCell,
            isShow = jet.isBool(opts.isShow),
            ishhmat = jet.mlen(that.format) == 7,
            multiPane = jet.isBool(opts.multiPane),
            isYYMM = jet.mlen(that.format) == 2,
            isYY = jet.mlen(that.format) == 1;
        //清空按钮清空日期时间
        boxCell.on("click",".clear", function(ev) {
            ev.stopPropagation();
            if (isShow){
                var type = jet.isValHtml(that.valCell) ? "val" : "text",
                    gtval = that.valCell[type](),
                    clearVal = that.setValue("");
                //that.dateClose();
                $(jet.boxelem).slideUp();
                setTimeout(function() {
                        that.dateClose();
                    },
                    500);
                if (gtval != "") {
                    if (jet.isBool(opts.clearRestore)){
                        jet.minDate = opts.startMin || jet.minDate;
                        jet.maxDate = opts.startMax || jet.maxDate;
                    }
                    if ($.isFunction(opts.clearfun) || opts.clearfun != null) opts.clearfun({elem:elemCell,val:clearVal});
                }
            }else {
                var cdate = that.getValue({});
                that.renderHtml(cdate[0].YYYY, cdate[0].MM,cdate[0].DD, opts,boxCell);
            }
            if(opts.range != false) that.delAreaAttr();
        });
        //今天（现在）按钮设置日期时间
        if(opts.range != false) boxCell.find(".today").hide();
        boxCell.on("click",".today", function() {
            var xDate = new Date(),
                objVal = {
                    YYYY:xDate.getFullYear(), MM:jet.digit(xDate.getMonth() + 1), DD:jet.digit(xDate.getDate()),
                    hh:jet.digit(xDate.getHours()), mm:jet.digit(xDate.getMinutes()), ss:jet.digit(xDate.getSeconds())
                };
            var thisdate = that.setValue(objVal);
            //that.dateClose();
            $(jet.boxelem).slideUp();
            setTimeout(function() {
                    that.dateClose();
                },
                500);
            if ($.isFunction(opts.okfun) || opts.okfun != null) opts.okfun({elem:elemCell,val:thisdate,date:objVal});
        });
        //确认按钮设置日期时间
        boxCell.on("click",".setok", function(ev) {
            ev.stopPropagation();
            var  sDate = new Date(),okVal,valdate,objVal;
            if(opts.range == false){
                var hmsVal = that.gethmsVal(boxCell),
                    dateVal = function () {
                        var ymdObj = {}, ymday = (isYYMM || isYY) ? ".ymcon":".daysul",
                            spval = jet.reMatch(boxCell.find(ymday).find("td.actdate").attr("je-val"));
                        $.each(spval,function (i,val) {
                            ymdObj[matArr[i]] = val;
                        });
                        var objVal = /\hh/.test(that.format) ? $.extend(ymdObj,hmsVal) : ymdObj;
                        return objVal;
                    };
                okVal = ishhmat ? hmsVal : dateVal();
            }else {
                var newobj = {}, newarea = [], hmsArr=[[],[]];
                boxCell.find(".timecon em").each(function(i) {
                    var disab = $(this).attr('disabled');
                    if(disab == undefined){
                        hmsArr[i>2 ? 1 : 0].push($(this).text());
                    }
                });
                if (jet.mlen(that.format) == 7){
                    if (opts.range != false){
                        $.each(hmsArr,function (i,val) {
                            var group = val.join("");
                            newobj[group] = val.join(":");
                            newarea.push(group);
                        });
                    }
                }else {
                    $.each(that.areaVal, function (n, val) {
                        var group = val + (/\hh/.test(that.format) ? " " + hmsArr[n].join(":") : "");
                        var repgroup = group.replace(/\s|-|:/g, "");
                        newobj[repgroup] = group;
                        newarea.push(repgroup);
                    });
                }
                var minVal = Math.min.apply(null, newarea), maxVal = Math.max.apply(null, newarea);
                okVal = newobj[minVal]+opts.range+newobj[maxVal];
            }
            if (isShow) {
                valdate = that.setValue(okVal);
                //that.dateClose();
                $(jet.boxelem).slideUp();
                setTimeout(function() {
                        that.dateClose();
                    },
                    500);
            }else {
                valdate = that.setValue(okVal,that.format,false);
            }
            if (opts.range == false){
                objVal = {
                    YYYY:okVal.YYYY||sDate.getFullYear(), MM:jet.digit(okVal.MM||sDate.getMonth() + 1),
                    DD:jet.digit(okVal.DD||sDate.getDate()), hh:jet.digit(okVal.hh||sDate.getHours()),
                    mm:jet.digit(okVal.mm||sDate.getMinutes()), ss:jet.digit(okVal.ss||sDate.getSeconds())
                };
            }else {
                var rans = that.setValue(okVal,that.format,false),objVal = [];
                $.each(new Array(2),function (i,v) {
                    var tmpval = {}, spra = jet.reMatch(rans.split(opts.range)[i]);
                    $.each(jet.reMatch(that.format),function (r,val) {
                        tmpval[val]=spra[r];
                    });
                    objVal.push(tmpval);
                });
            }
            if ($.isFunction(opts.okfun) || opts.okfun != null) opts.okfun({elem:elemCell,val:valdate,date:objVal});
        });
    };
    jedfn.clickTime = function (opts,boxCell) {
        var that = this;
        if(/\hh/.test(that.format)){
            var timeUl = that.maincon(".timebox",1).find("ul");
            timeUl.on("click","li",function () {
                var lithis = $(this);
                var ulidx = lithis.parent().attr("idx"),
                    hmsval = lithis.text();
                if (lithis.hasClass("disabled")) return;
                lithis.addClass('action bg_title').siblings().removeClass('action bg_title');
                boxCell.find(".timecon em").eq(ulidx).text(hmsval);
                //计算当前时分秒的位置
                that.locateScroll(timeUl);
            });
        }
    };
    //计算当前选中的滚动条位置
    jedfn.locateScroll = function (cell) {
        $.each(cell, function() {
            var hmsCls = $(this), achmsCls = hmsCls.find(".action");
            var acNUm = (achmsCls.length > 0) ? (achmsCls[0].offsetTop - 114):0;
            hmsCls[0].scrollTop = acNUm;
        });
    };
    //农历方位辨别
    jedfn.lunarOrien = function(obj, self, pos) {
        var tops, leris, ortop, orleri, rect =self[0].getBoundingClientRect();
        leris = rect.right + obj[0].offsetWidth / 1.5 >= jet.docArea(1) ? rect.right - obj[0].offsetWidth : rect.left + (pos ? 0 : jet.docScroll(1));
        tops = rect.bottom + obj[0].offsetHeight / 1 <= jet.docArea() ? rect.bottom - 1 : rect.top > obj[0].offsetHeight / 1.5 ? rect.top - obj[0].offsetHeight - 1 : jet.docArea() - obj[0].offsetHeight;
        ortop = Math.max(tops + (pos ? 0 :jet.docScroll()) + 1, 1) + "px", orleri = leris + "px";
        return {top: ortop, left: orleri }
    };
    //辨别控件的方位
    jedfn.dateOrien = function(boxCls, valCls, pos) {
        var that = this, tops, leris, ortop, orleri;
        var rect = that.fixed ? valCls[0].getBoundingClientRect() : boxCls[0].getBoundingClientRect();
        var leris = rect.left;
        var tops = rect.bottom - 1;

        if(that.fixed) {
            var boxW = boxCls.outerWidth(), boxH = boxCls.outerHeight();
            //如果右侧超出边界
            /*if(leris + boxW > jet.docArea(true)){
                leris = jet.docArea(true) - boxW;
            }*/
            //如果底部超出边界
            /*if(tops + boxH > jet.docArea()){
                tops = rect.top > boxH ? rect.top - boxH -2 : jet.docArea() - boxH -1;
            }*/
            //根据目标元素计算弹层位置
            ortop = Math.max(tops + (pos ? 0 :jet.docScroll())+1, 1) + "px", orleri = leris + "px";
        }else{
            //弹层位置位于页面上下左右居中
            ortop = "50%", orleri = "50%";
            boxCls.css({"margin-top":-(rect.height / 2),"margin-left":-(rect.width / 2)});
        }
        boxCls.css({"top":ortop,"left":orleri});
    };
    jedfn.tips = function (text, time) {
        var that = this, tipCls = $(jet.boxelem).find(".ak-DateTime-tips");
        tipCls.html("").html(text||"").show();
        clearTimeout(that.tipTime);
        that.tipTime = setTimeout(function(){
            tipCls.html("").hide();
        }, (time||2.5)*1000);
    };
    //关闭层
    jedfn.dateClose = function() {
        if($($(jet.boxelem).attr(jefix)).length == 0) $(jet.boxelem).remove();
    };
    //日期大小比较
    jedfn.dateContrast = function (ac, bc) {
        var sarr = ac.split("-"), earr = bc.split("-"),
            start = parseInt(sarr[0]+""+jet.digit(parseInt(sarr[1])-1)+""+jet.digit(sarr[2]||"01")),
            end = parseInt(earr[0]+""+jet.digit(parseInt(earr[1])-1)+""+jet.digit(sarr[2]||"01"));
        return (start >= end) ? false : true;
    };
    //删除区域属性
    jedfn.delAreaAttr = function () {
        delete this.areaStart;
        delete this.areaEnd;
        this.areaVal = [];
    };
    //返回指定日期
    $.nowDate = function (str,format) {
        format = format || 'YYYY-MM-DD hh:mm:ss';
        if (typeof(str) === 'number') {
            str = {DD: str};
        }
        return jet.GetDateTime(str, format);
    };
    //日期时间戳相互转换
    $.timeStampDate = function (date,format) {
        format = format || 'YYYY-MM-DD hh:mm:ss';
        var dateTest = (/^(-)?\d{1,10}$/.test(date) || /^(-)?\d{1,13}$/.test(date));
        if(/^[1-9]*[1-9][0-9]*$/.test(date) && dateTest){
            var vdate = parseInt(date);
            if (/^(-)?\d{1,10}$/.test(vdate)) {
                vdate = vdate * 1000;
            } else if (/^(-)?\d{1,13}$/.test(vdate)) {
                vdate = vdate * 1000;
            } else if (/^(-)?\d{1,14}$/.test(vdate)) {
                vdate = vdate * 100;
            } else {
                return;
            }
            var setdate = new Date(vdate);
            return jet.parse({YYYY:setdate.getFullYear(), MM:jet.digit(setdate.getMonth()+1), DD:jet.digit(setdate.getDate()) , hh:jet.digit(setdate.getHours()), mm:jet.digit(setdate.getMinutes()), ss:jet.digit(setdate.getSeconds()) }, format);
        }else {
            //将日期转换成时间戳
            var arrs = jet.reMatch(date),
                newdate = new Date(arrs[0],parseInt(arrs[1])-1,arrs[2],arrs[3]||0,arrs[4]||0,arrs[5]||0),
                timeStr = Math.round(newdate.getTime() / 1000);
            return timeStr;
        }
    };
    //分解日期时间
    $.splitDate = function (str) {
        var sdate = str.match(/\w+|d+/g);
        return {
            YYYY:parseInt(sdate[0]),MM:parseInt(sdate[1])||00,DD:parseInt(sdate[2])||00,
            hh:parseInt(sdate[3])||00,mm:parseInt(sdate[4])||00,ss:parseInt(sdate[5])||00
        };
    };
    //获取年月日星期
    $.getLunar = function(date,format){
        var that = this;
        format = format || 'YYYY-MM-DD hh:mm:ss';
        if(/YYYY-MM-DD/g.test(jet.isparmat(format))){
            //如果为数字类型的日期对获取到日期的进行替换
            var charDate = date.substr(0,4).replace(/^(\d{4})/g,"$1,") + date.substr(4).replace(/(.{2})/g,"$1,"),
                reArr = jet.isNum(date) ? jet.reMatch(charDate) : jet.reMatch(date),
                lunars = that.jeLunar(reArr[0], reArr[1] - 1, reArr[2]);
            return{
                nMonth: lunars.lnongMonth,             //农历月
                nDays: lunars.lnongDate,               //农历日
                yYear: parseInt(lunars.solarYear),     //阳历年
                yMonth: parseInt(lunars.solarMonth),   //阳历月
                yDays: parseInt(lunars.solarDate),     //阳历日
                cWeek: lunars.inWeekDays,              //汉字星期几
                nWeek: lunars.solarWeekDay             //数字星期几
            };
        }
    };
    return Andrew_DateTime;
}(jQuery));

/*-----------------------------------------------Andrew_Dialog------------------------------------------*/
(function($){
    var m = {};
    var g = {};
    m.opening = false;
    m._options = {
        title: false,
        animateIn : "bounceInDown",
        animateOut : "bounceOutUp",
        onSubmit : false,
        onCancel : false,
        required: false,
        icon: false,
        inputbox: false,
        inputType: "",
        inputClass: "",
        placeholder:"",
        button_ok: "OK",
        button_cancel: "CANCEL"
    };

    m.tplBase = "<div class=\"ak-dialog\">";
    m.tplBase += "<div class=\"ak-dialog_container\">";
    m.tplBase += "{{header}}";
    m.tplBase += "<div class=\"ak-dialog_content\"><p>{{message}}</p>{{input}}</div>";
    m.tplBase += "<div class=\"ak-dialog_footer\">{{button_cancel}} <button type=\"button\" class=\"jq_btn bg_white button_ok c_title\">{{btn_ok}}</button></div>";
    m.tplBase += "</div>";
    m.tplBase += "</div>";

    m.tplHeader = "<div class=\"ak-dialog_header bor_bottom_dashed bor_gray_ddd {{icon}}\"><h3 class=\"ml_05em\">{{title}}</h3></div>";
    m.tplInput = "<div class=\"ak-dialog_field\">{{inputbox}}</div>";

    m.getTeplate = function(type, message, options){
        var t = m.tplBase;

        if( type !== 'alert' ){
            t = t.replace("{{button_cancel}}", "<button type=\"button\" class=\"jq_btn bg_white button_cancel bor_right bor_gray_ddd\">{{btn_cancel}}</button>");
        } else {
            t = t.replace("{{button_cancel}}", "");
        }
        if( type == 'prompt' ){
            t = t.replace("{{input}}", m.tplInput);
        } else {
            t = t.replace("{{input}}", "");
        }
        if( options.title ){
            t = t.replace("{{header}}", m.tplHeader.replace("{{title}}", options.title) );
        } else {
            t = t.replace("{{header}}", "");
        }
        if (options.inputbox == 'textarea') {
            t = t.replace("{{inputbox}}", "<textarea />");
        } else if (options.inputbox == 'input') {
            if (options.inputType) {
                t = t.replace("{{inputbox}}", "<input type='"+options.inputType+"' />");
            } else {
                t = t.replace("{{inputbox}}", "<input type='text' />");
            }
        }
        t = t.replace("{{icon}}", options.icon);
        t = t.replace("{{btn_ok}}", options.button_ok);
        t = t.replace("{{btn_cancel}}", options.button_cancel);
        t = t.replace("{{message}}", message );
        return t;
    };

    m.clear = function() {
        $('#alert_mask').length ? $('#alert_mask').remove() : '';
        $('.ak-dialog').length ? $('.ak-dialog').remove() : '';
    };

    m.Dialog = function() {
        var that = this;

        that.close = function() {
            $("main").addClass("scrolling");
            if (that.options.animateOut) {
                if (that.options.animateIn) {
                    that.container.find('.ak-dialog_container').removeClass(that.options.animateIn)
                }
                that.container.find('.ak-dialog_container').addClass('animated ' + that.options.animateOut);
                setTimeout(function() {
                        that.container.removeClass('ak-is_active');
                        that.container.remove();
                        m.opening = false;
                        $('#alert_mask').remove();
                    },
                    800);
            } else {
                that.container.remove();
                m.opening = false;
                $('#alert_mask').remove();
            }
        };

        that.addEvents = function(){
            that.btnOk.on("click", function(e){
                e.preventDefault();
                var res = false;
                if( that.field.length ){
                    if( that.options.required == true && !that.field.val().length ){
                        that.field.addClass('is-invalid');
                        return false;
                    } else {
                        that.field.removeClass('is-invalid');
                        res = that.field.val();
                    }
                } else {
                    res = true;
                }
                if( typeof that.options.onSubmit == 'function' ){
                    that.options.onSubmit(res);
                }
                that.close();
            });
            that.btnCancel.on("click", function(e){
                e.preventDefault();
                var res = false;
                if( that.field.length && that.field.val().length !== 0 ){
                    res = that.field.val();
                }
                if( typeof that.options.onCancel == 'function' ){
                    that.options.onCancel(res);
                }
                that.close();
            });
        };

        this.init = function(type, message, options, defaultValue){
            if (m.opening) {
                $('#alert_mask, .ak-dialog').remove();
            }
            m.clear();

            that.options = m.getOptions(options);
            $('body').append(m.getTeplate(type, message, that.options) + "<div id='alert_mask' class=\"ak-mask\"></div> ");
            that.container = $('body').find('.ak-dialog');

            $("main").removeClass("scrolling");
            that.btnOk = that.container.find('.button_ok');
            that.btnCancel = that.container.find('.button_cancel');
            if (options.inputbox == 'textarea') {
                that.field = that.container.find('textarea');
            } else {
                that.field = that.container.find('input');
            }
            if (options.placeholder) {
                that.field.attr("placeholder", options.placeholder);
                var placeholder_tmps ="";
                that.field.focus(function() {
                    placeholder_tmps = $(this).attr("placeholder");
                    if ($(this)[0].type !="search") {
                        $(this).removeAttr('placeholder');
                    }
                    $(this).blur(function() {
                        $(this).attr("placeholder",placeholder_tmps);
                    });
                });
            }
            that.field.parents('.ak-dialog_content').children("p").addClass("ak-input_title");
            that.field.addClass(options.inputClass);
            if( defaultValue && that.field.length ){
                that.field.val(defaultValue);
            }
            that.container.addClass('ak-is_active').css({
                "top": ($(window).height() / 2) - (that.container.height() / 2)
            });
            if( that.options.animateIn ){
                that.container.find('.ak-dialog_container').addClass('animated '+that.options.animateIn);
            }
            m.opening = true;

            that.addEvents();
        };
    };

    m.getOptions = function(options){
        var o = $.extend({}, m._options);
        if( typeof options == 'object' ){
            $.each(options, function(key, val){
                o[key] !== undefined ? o[key] = val : console.error("The option \""+key+"\" not exist.");
            });
        }
        return o;
    };

    //global functions
    var isIE = function () {
        var U = navigator.userAgent,
            IsIE = U.indexOf('MSIE') > -1,
            a = IsIE ? /\d+/.exec(U.split(';')[1]) : 'no ie';return a <= 8;
    }();
    if(!isIE){
        alert = function (message, userOptions) {
            var message = message || "";
            var userOptions = userOptions || {};
            var dialog = new m.Dialog;
            dialog.init('alert', message, userOptions);
        };
        confirm = function (message, userOptions) {
            var message = message || "";
            var userOptions = userOptions || {};
            var dialog = new m.Dialog;
            dialog.init('confirm', message, userOptions);
        };
        prompt = function (message, defaultValue, userOptions) {
            var message = message || "";
            var userOptions = userOptions || {};
            var dialog = new m.Dialog;
            dialog.init('prompt', message, userOptions, defaultValue);
        };
    }
    g.alert = function(message, userOptions){ //解决微信不支持问题
        var message = message || "";
        var userOptions = userOptions || {};
        var dialog = new m.Dialog;
        dialog.init('alert', message, userOptions);
    };
    g.confirm = function(message, userOptions){ //解决微信不支持问题
        var message = message || "";
        var userOptions = userOptions || {};
        var dialog = new m.Dialog;
        dialog.init('confirm', message, userOptions);
    };
    g.prompt = function(message, defaultValue, userOptions){ //解决微信不支持问题
        var message = message || "";
        var userOptions = userOptions || {};
        var dialog = new m.Dialog;
        dialog.init('prompt', message, userOptions, defaultValue);
    };
    g.config = function(options){
        if( typeof options !== 'object' ){ return false; }
        $.each(options, function(key, val){
            m._options[key] !== undefined ? m._options[key] = val : console.error("The option \""+key+"\" not exist.");
        });
    };
    $ak = g;
}(jQuery));

/*-----------------------------------------------Andrew_StairsMenu-------------------------------------------*/
(function($){
    $.fn.Andrew_StairsMenu = function(setting) {
        var option = $.extend({
                Stairs_Class: "",
                Stairs_Content: ""
            },
            setting);
        var Stairs_Link = $(this);
        var Stairs_Content = option.Stairs_Content;
        $(window).scroll(function(){
            var winH = $(window).height();//可视窗口高度
            var iTop = $(window).scrollTop();//鼠标滚动的距离

            //鼠标滑动式改变
            Stairs_Content.each(function(){
                //console.log($(this).offset().top)
                if ($("header").length >0) {
                    var winH_Scroll = winH - $("header").outerHeight();
                } else {
                    var winH_Scroll = winH;
                }
                if(winH+iTop+Stairs_Link.outerHeight() - $(this).offset().top >= winH_Scroll){
                    Stairs_Link.eq($(this).index()).addClass(option.Stairs_Class).siblings().removeClass(option.Stairs_Class);
                }
            });
        });
        Stairs_Link.on('click', function(e){
            e.stopPropagation();
            if ($("header").length >0) {
                var Stairs_Scroll = Stairs_Content.eq($(this).index()).offset().top-$("header").outerHeight();
            } else {
                var Stairs_Scroll = Stairs_Content.eq($(this).index()).offset().top;
            }
            $('body,html').animate({"scrollTop":Stairs_Scroll},500);
            $(this).addClass(option.Stairs_Class).siblings().removeClass(option.Stairs_Class);
        });
    };
}(jQuery));
/*-----------------------------------------------Andrew_FloatFixed-------------------------------------------*/
(function($){
    $.fn.Andrew_FloatFixed = function(setting) {
        var option = $.extend({
                floats: "left",
                show: true,
                zindex: 2,
                deploy_icon: "",
                close_icon: "",
                close_btn: ""
            },
            setting);
        var Ele = $(this);
        var WinHet = $(window).height();
        var EleHet= Ele.height();
        var fixedTop = WinHet / 2;
        Ele.append("<button class='ak-btn "+option.close_btn+"'><i></i></button>");

        if (option.show == true) {
            Ele.find(".ak-btn i").addClass(option.close_icon);
        } else {
            Ele.find(".ak-btn i").addClass(option.deploy_icon);
        }

        if (option.floats == "left") {
            if (option.show == true) {
                Ele.css({
                    "left": 0
                });
            } else {
                Ele.css({
                    "left": -Ele.children("button").eq(0).outerWidth()
                });
            }
            Ele.css({
                "top": fixedTop,
                "position": "fixed",
                "z-index": option.zindex
            });
            Ele.find(".ak-btn").css({
                "top": Ele.outerHeight()/2,
                "left": Ele.children("button").eq(0).outerWidth(),
                "position": "absolute",
                "z-index": option.zindex+1
            });
        } else if (option.floats == "right") {
            if (option.show == true) {
                Ele.css({
                    "right": 0
                });
            } else {
                Ele.css({
                    "right": -Ele.children("button").eq(0).outerWidth()
                });
            }
            Ele.css({
                "top": fixedTop,
                "position": "fixed",
                "z-index": option.zindex
            });
            Ele.find(".ak-btn").css({
                "top": Ele.outerHeight()/2,
                "right": Ele.children("button").eq(0).outerWidth(),
                "position": "absolute",
                "z-index": option.zindex+1
            });
        }
        Ele.find(".ak-btn").on('click', function(){
            if ($(this).children("i").hasClass(option.close_icon)) {
                $(this).children("i").removeClass().addClass(option.deploy_icon);
                if (option.floats == "left") {
                    $(this).parent().stop().animate({
                        "left": -$(this).parent().children("button").eq(0).outerWidth()
                    });
                } else if (option.floats == "right") {
                    $(this).parent().stop().animate({
                        "right": -$(this).parent().children("button").eq(0).outerWidth()
                    });
                }
            } else {
                $(this).children("i").removeClass().addClass(option.close_icon);
                if (option.floats == "left") {
                    $(this).parent().stop().animate({
                        "left": 0
                    });
                } else if (option.floats == "right") {
                    $(this).parent().stop().animate({
                        "right": 0
                    });
                }
            }
        });
        $(window).scroll(scrolls);
        scrolls();
        function scrolls(){
            Ele.stop().animate({
                top: fixedTop - EleHet
            });
        }
    };
}(jQuery));
/*-----------------------------------------------Andrew_PassLevel------------------------------------------*/
(function($){
    $.fn.Andrew_PassLevel = function(setting) {
        var option = $.extend({
                O_color: "#eeeeee",
                L_color: "#ffd8b4",
                M_color: "#ffaf56",
                H_color: "#e85959",
                L_text: "L",
                M_text: "M",
                H_text: "H",
            },
            setting);
        var pl = $(this);
        var O_color = option.O_color;
        var L_color = option.L_color;
        var M_color = option.M_color;
        var H_color = option.H_color;
        pl.each(function(){
            $(this).next().children("li").css('background-color', option.O_color);
            $(this).after('<ul class="ak-PassLevel"><li class="strength_L">'+option.L_text+'</li><li class="strength_M">'+option.M_text+'</li><li class="strength_H">'+option.H_text+'</li></ul>');
            $(this).next().hide();
            $(this).on('keyup', function(e) {
                $(this).next().show();
                ak_pwStrength(this.value);
                $(this).next().children(".strength_L").css('background-color', Lcolor);
                $(this).next().children(".strength_M").css('background-color', Mcolor);
                $(this).next().children(".strength_H").css('background-color', Hcolor);
                if ($(this).val() == 0) {
                    $(this).next().hide();
                }
            });
        });
        function ak_pwStrength(pwd) {
            if (pwd == null || pwd == '') {
                Lcolor = Mcolor = Hcolor = O_color;
            } else {
                S_level = ak_checkStrong(pwd);
                switch (S_level) {
                    case 0:
                        Lcolor = Mcolor = Hcolor = O_color;
                    case 1:
                        Lcolor = L_color;
                        Mcolor = Hcolor = O_color;
                        break;
                    case 2:
                        Lcolor = L_color;
                        Mcolor = M_color;
                        Hcolor = O_color;
                        break;
                    default:
                        Lcolor = L_color;
                        Mcolor = M_color;
                        Hcolor = H_color;
                }
            }
            return;
        }
        //判断输入密码的类型
        function ak_CharMode(iN) {
            if (iN >= 48 && iN <= 57) //数字
                return 1;
            if (iN >= 65 && iN <= 90) //大写
                return 2;
            if (iN >= 97 && iN <= 122) //小写
                return 4;
            else return 8;
        }
        //bitTotal函数
        //计算密码模式
        function ak_bitTotal(num) {
            modes = 0;
            for (i = 0; i < 4; i++) {
                if (num & 1) modes++;
                num >>>= 1;
            }
            return modes;
        }
        //返回强度级别
        function ak_checkStrong(sPW) {
            if (sPW.length <= 4) return 0; //密码太短
            Modes = 0;
            for (i = 0; i < sPW.length; i++) {
                //密码模式
                Modes |= ak_CharMode(sPW.charCodeAt(i));
            }
            return ak_bitTotal(Modes);
        }
    };
}(jQuery));

/*-----------------------------------------------Andrew_ChinaSelCity-------------------------------------------*/
(function($){
    $.fn.Andrew_ChinaSelCity = function(setting) {
        var opm = $.extend({
                tab_title:"",
                callback: function() {
                }
            },
            setting);
        var city =$(this);
        city.click(function (e) {
            ChinaSelCity(this,e);
            $(".ak-ChinaSelCity").slideToggle();
            $(".ak-ChinaSelCity").toggleClass('ak-is_active');
            //event.stopPropagation(e);
            e.stopPropagation();
        });
        function ChinaSelCity(obj,e) {
            var ths = obj;
            var dal = '<div class="ak-ChinaSelCity">' +
                '<span class="c_title bor_title" id="cColse" >×</span>' +
                '<ul id="ak-ChinaSelCity_province" class="ak-ChinaSelCity0 bor_bottom2 bor_title">' +
                '<li class="bg_title c_white">'+opm.tab_title[0]+'</li>' +
                '<li>'+opm.tab_title[1]+'</li>' +
                '<li>'+opm.tab_title[2]+'</li>' +
                '</ul>' +
                '<div id="ak-ChinaSelCity0" class="ak-ChinaSelCity1"></div>' +
                '<div style="display:none" id="ak-ChinaSelCity1" class="ak-ChinaSelCity1"></div>' +
                '<div style="display:none" id="ak-ChinaSelCity2" class="ak-ChinaSelCity1"></div>' +
                '</div>';
            if ($(".ak-ChinaSelCity").length === 0) {
                $('body').append(dal).addClass("ak-is_active");
            }
            if ($(".ak-ChinaSelCity").hasClass('ak-is_active')) {
                $(".ak-ChinaSelCity").slideDown();
            } else {
                $(".ak-ChinaSelCity").slideUp();
            }
            $(".ak-ChinaSelCity").css({
                "width": $(ths).outerWidth(),
                "top":$(ths).offset().top + $(ths).outerHeight(),
                "left":$(ths).offset().left,
            });
            $("#cColse").click(function () {
                $(".ak-ChinaSelCity").slideUp();
                setTimeout(function() {
                        $(".ak-ChinaSelCity").remove();
                    },
                    500);
            });
            $("body").on('click', function(e) {
                e.stopPropagation();
                $(".ak-ChinaSelCity").slideUp();
                setTimeout(function() {
                        $(".ak-ChinaSelCity").remove();
                    },
                    500);
            });
            var tb_province = [];
            var b = province;
            for (var i = 0, len = b.length; i < len; i++) {
                tb_province.push('<a data-level="0" data-id="' + b[i]['id'] + '" data-name="' + b[i]['name'] + '">' + b[i]['name'] + '</a>');
            }
            $("#ak-ChinaSelCity0").append(tb_province.join(""));
            $("#ak-ChinaSelCity0 a").click(function (e) {
                e.stopPropagation();
                $(".ak-ChinaSelCity").show();
                var g = getCity($(this));
                $("#ak-ChinaSelCity1 a").remove();
                $("#ak-ChinaSelCity1").append(g);
                $(".ak-ChinaSelCity1").hide();
                $(".ak-ChinaSelCity1:eq(1)").show();
                $("#ak-ChinaSelCity0 a,#ak-ChinaSelCity1 a,#ak-ChinaSelCity2 a").removeClass("bg_title c_white");
                $(this).addClass("bg_title c_white");
                var lev = $(this).data("name");
                ths.value = $(this).data("name");
                if (document.getElementById("hcity") == null) {
                    var hcitys = $('<input>', {
                        type: 'hidden',
                        name: "hcity",
                        "data-id": $(this).data("id"),
                        id: "hcity",
                        val: lev
                    });
                    $(ths).after(hcitys);
                }
                else {
                    $("#hcity").val(lev);
                    $("#hcity").attr("data-id", $(this).data("id"));
                }
                $("#ak-ChinaSelCity1 a").click(function (e) {
                    e.stopPropagation();
                    $(".ak-ChinaSelCity").show();
                    $("#ak-ChinaSelCity1 a,#ak-ChinaSelCity2 a").removeClass("bg_title c_white");
                    $(this).addClass("bg_title c_white");
                    var lev =  $(this).data("name");
                    if (document.getElementById("hproper") == null) {
                        var hcitys = $('<input>', {
                            type: 'hidden',
                            name: "hproper",
                            "data-id": $(this).data("id"),
                            id: "hproper",
                            val: lev
                        });
                        $(ths).after(hcitys);
                    }
                    else {
                        $("#hproper").attr("data-id", $(this).data("id"));
                        $("#hproper").val(lev);
                    }
                    var bc = $("#hcity").val();
                    ths.value = bc+ "-" + $(this).data("name");

                    var ar = getArea($(this));

                    $("#ak-ChinaSelCity2 a").remove();
                    $("#ak-ChinaSelCity2").append(ar);
                    $(".ak-ChinaSelCity1").hide();
                    $(".ak-ChinaSelCity1:eq(2)").show();

                    $("#ak-ChinaSelCity2 a").click(function (e) {
                        e.stopPropagation();
                        $(".ak-ChinaSelCity").show();
                        $("#ak-ChinaSelCity2 a").removeClass("bg_title c_white");
                        $(this).addClass("bg_title c_white");
                        var lev = $(this).data("name");
                        if (document.getElementById("harea") == null) {
                            var hcitys = $('<input>', {
                                type: 'hidden',
                                name: "harea",
                                "data-id": $(this).data("id"),
                                id: "harea",
                                val: lev
                            });
                            $(ths).after(hcitys);
                        }
                        else {
                            $("#harea").val(lev);
                            $("#harea").attr("data-id", $(this).data("id"));
                        }
                        var bc = $("#hcity").val();
                        var bp = $("#hproper").val();
                        ths.value = bc + "-" + bp + "-" + $(this).data("name");
                        opm.callback(city,$(this).data("id"),bc,bp,$(this).data("name"));
                        $(".ak-ChinaSelCity").remove();
                    });

                });
            });
            $("#ak-ChinaSelCity_province li").click(function (e) {
                e.stopPropagation();
                $(".ak-ChinaSelCity").show();
                $("#ak-ChinaSelCity_province li").removeClass("bg_title c_white");
                $(this).addClass("bg_title c_white");
                var s = $("#ak-ChinaSelCity_province li").index(this);
                $(".ak-ChinaSelCity1").hide();
                $(".ak-ChinaSelCity1:eq(" + s + ")").show();
            });
        }
        function getCity(obj) {
            var c = obj.data('id');
            var e = province;
            var f;
            var g = '';
            for (var i = 0, plen = e.length; i < plen; i++) {
                if (e[i]['id'] == parseInt(c)) {
                    f = e[i]['city'];
                    break
                }
            }
            for (var j = 0, clen = f.length; j < clen; j++) {
                g += '<a data-level="1" data-id="' + f[j]['id'] + '" data-name="' + f[j]['name'] + '" title="' + f[j]['name'] + '">' + f[j]['name'] + '</a>'
            }
            $("#ak-ChinaSelCity_province li").removeClass("bg_title c_white");
            $("#ak-ChinaSelCity_province li:eq(1)").addClass("bg_title c_white");
            return g;
        }
        function getArea(obj) {
            var c = obj.data('id');
            var e = area;
            var f = [];
            var g = '';
            for (var i = 0, plen = e.length; i < plen; i++) {
                if (e[i]['pid'] == parseInt(c)) {
                    f.push(e[i]);
                }
            }
            for (var j = 0, clen = f.length; j < clen; j++) {
                g += '<a data-level="1" data-id="' + f[j]['id'] + '" data-name="' + f[j]['name'] + '" title="' + f[j]['name'] + '">' + f[j]['name'] + '</a>'
            }

            $("#ak-ChinaSelCity_province li").removeClass("bg_title c_white");
            $("#ak-ChinaSelCity_province li:eq(2)").addClass("bg_title c_white");
            return g;
        }
    };
}(jQuery));

/*-----------------------------------------------Andrew_CitySelect------------------------------------------*/
(function($){
    var regEx = /^([\u4E00-\u9FA5\uf900-\ufa2d]+)\|(\w+)\|(\w)\w*$/i, // 匹配汉字，拼音
        regExChiese = /([\u4E00-\u9FA5\uf900-\ufa2d]+)/, // 只匹配拼音
        reg_ah = /^[a-h]$/i, // 匹配首字母为 a-h
        reg_ip = /^[i-p]/i, // 匹配首字母为 i-p
        reg_qz = /^[q-z]/i; // 匹配首字母为 q-z
    //构建城市分类字面量
    var city = {
        hot: {},
        ABCDEFGH: {},
        IJKLMNOP: {},
        QRSTUVWXYZ: {}
    };
    //城市按首字母分类，填充到分类字面量
    (function() {
        for (var i = 0, len = CityData.length; i < len; i++) {
            var part = regEx.exec(CityData[i]),
                en = part[1], //中文名
                letter = part[2], //拼音
                spletter = part[3], //拼音简写
                first = letter[0].toUpperCase(), //拼音首字母
                ltPart; //当前字母下的城市
            if (reg_ah.test(first)) {
                ltPart = 'ABCDEFGH';
            } else if (reg_ip.test(first)) {
                ltPart = 'IJKLMNOP';
            } else if (reg_qz.test(first)) {
                ltPart = 'QRSTUVWXYZ';
            }
            city[ltPart][first] ? city[ltPart][first].push(en) : (city[ltPart][first] = [], city[ltPart][first].push(en));
            //设置前16个城市为热门城市
            if (i < 16) {
                city.hot['hot'] ? city.hot['hot'].push(part[1]) : (city.hot['hot'] = [], city.hot['hot'].push(part[1]));
            }
        }
    })();

    var Andrew_CitySelect = function(target) {
        this.target = target; // // 输入框
        this.container = null; //插件容器
        this.resultct = null; //搜索结果容器
        this.isKeyslect = false; //是否在用上下键选择
        this.isContainerExit = false; // 插件容器是否已存在
    };
    Andrew_CitySelect.prototype = {
        constructor: Andrew_CitySelect,
        //初始化
        init: function() {
            this.creatItem();
            this.tabChange();
            this.citySelect();
            this.inputSearch();
            this.keySelect();
            this.stopPropagation();
        },
        //创建市列表
        creatItem: function() {
            if(this.isContainerExit) return;
            var template = '<div class="ak-CitySelect" id="'+ak_CitySelect.setting.layer_name+'">' +
                '<div class="citybox">' +
                '<h3 class="ak-CitySelect_header c_title">'+ak_CitySelect.setting.title+'</h3>' +
                '<ul class="ak-CitySelect_nav">' +
                '<li class="bg_title bor_title c_white">'+ak_CitySelect.setting.subject+'</li>' +
                '<li>ABCDEFGH</li>' +
                '<li>IJKLMNOP</li>' +
                '<li>QRSTUVWXYZ</li>' +
                '</ul>' +
                '<div class="ak-CitySelect_body"></div>' +
                '</div>' +
                '<ul class="ak-result"></ul>' +
                '</div>';
            $('body').append(template);
            this.container = $("#"+ak_CitySelect.setting.layer_name);
            this.resultct = $('.ak-result');
            for (var group in city) {
                var itemKey = [];
                for (var item in city[group]) {
                    itemKey.push(item);
                }
                itemKey.sort();
                var itembox = $('<div class="ak-CitySelect_item">');
                itembox.addClass(group);
                for (var i = 0, iLen = itemKey.length; i < iLen; i++) {
                    var dl = $('<dl>'),
                        dt = '<dt class="c_title">' + (itemKey[i] == 'hot' ? '' : itemKey[i]) + '</dt>',
                        dd = $('<dd>'),
                        str = '';
                    for (var j = 0, jLen = city[group][itemKey[i]].length; j < jLen; j++) {
                        str += '<span>' + city[group][itemKey[i]][j] + '</span>'
                    }
                    dd.append(str);
                    dl.append(dt).append(dd);
                    itembox.append(dl);
                }
                this.container.find('.ak-CitySelect_body').append(itembox);
                this.container.find('.hot').addClass('ak-is_active');
            }
            this.isContainerExit = true;
        },
        //创建搜索结果列表
        creatResult: function(re, value) {
            var result = re.result,
                len = result.length,
                str = '';
            if (!!len) {
                for (var i = 0; i < len; i++) {
                    str += '<li><span class="name">' + result[i].cityName + '</span><span class="letter">' + result[i].py + '</span></li>'
                }
                this.container.find('.ak-result').html('').html(str).eq(0).addClass('ak-is_active');
            } else {
                this.container.find('.ak-result').html('<li>'+ak_CitySelect.setting.error+'<span class="ak-noresult c_orange text_bold">' + value + '</span></li>');
            }
        },
        //列表切换
        tabChange: function() {
            ak_CitySelect.container.find('.ak-CitySelect_nav').on('click', 'li', function(e) {
                e.stopPropagation();
                ak_CitySelect.container.show();
                var current = $(e.target),
                    index = current.index();
                current.addClass('bg_title bor_title c_white').siblings().removeClass('bg_title bor_title c_white');
                ak_CitySelect.container.find('.ak-CitySelect_item').eq(index).addClass('ak-is_active').siblings().removeClass('ak-is_active');
                ak_CitySelect.container.find(' .ak-CitySelect_body').scrollTop(0);

            })
        },
        //城市选择
        citySelect: function() {
            var self = this;
            this.container.find('.ak-CitySelect_item dd').on('click', 'span', function(e) {
                $(ak_CitySelect.setting.search_input).val(($(e.target).text()));
                self.container.slideUp();
                ak_CitySelect.setting.callback(($(e.target).text()));
            })
        },
        //上下键选择搜索结果
        keySelect: function() {
            var self = this;
            this.target.on('keydown', function(e){
                var current = self.resultct.find('.ak-is_active').index();
                if(current !== -1){
                    switch(e.keyCode){
                        //上
                        case 38:
                            keyActive(false);
                            break;
                        //下
                        case 40:
                            keyActive(true);
                            break;
                        //确定
                        case 13:
                            self.isKeyslect = false;
                            self.target.val(self.resultct.find('.ak-is_active .name').text());
                            self.triggleShow('all');
                            self.target.blur();
                            break;
                        default:
                            self.isKeyslect = false;
                            break;
                    }

                    function keyActive(isInorder) {
                        var max = self.resultct.length - 1;
                        if(isInorder){
                            current = current == max ? 0 : current + 1;
                        }else{
                            current = current == 0 ? max : current - 1;
                        }
                        self.resultct.eq(current).addClass('ak-is_active').siblings().removeClass('ak-is_active');
                        self.isKeyslect = true;
                    }
                }
            })
        },
        //搜索
        inputSearch: function() {
            var self = this;
            this.target.on('keyup', function(e) {
                if(!self.isKeyslect){
                    self.throttle(search, this);
                }
            });
            // 输入框搜索
            function search(e) {
                var container = self.container;
                self.triggleShow(false);
                var value = $(this).val();
                if (value) {
                    var url = ak_CitySelect.setting.apiurl + value;
                    $.ajax({
                        url: url,
                        type: 'get',
                        dataType: 'jsonp'
                    }).done(function(re) {
                        self.creatResult(re, value);
                    })
                } else {
                    self.triggleShow(true);
                }
            }
        },
        //列表，结果，整体 显示切换
        triggleShow: function(open) {
            var container = this.container;
            if (open === 'all') {
                container.hide()
            } else if (open) {
                container.find('.citybox').show().end().find('.ak-result').hide();
            } else {
                container.find('.citybox').hide().end().find('.ak-result').show();
            }
        },
        //函数节流
        throttle: function(fn, context) {
            clearTimeout(fn.tId);
            fn.tId = setTimeout(function(){
                fn.call(context);
            }, 100)
        },
        //阻止事件冒泡
        stopPropagation: function() {
            var self = this;
            //页面点击 隐藏
            $("body").on('click', function(e) {
                e.stopPropagation();
                self.container.slideUp();
                /*setTimeout(function() {
                        self.container.remove();
                    },
                    500);*/
            });
        }
    };
    var ak_CitySelect = null;
    $.fn.Andrew_CitySelect = function(setting) {
        var target = $(this);
        target.on('click', function(e) {
            e.stopPropagation();
            ak_CitySelect = ak_CitySelect ? ak_CitySelect : new Andrew_CitySelect(target,setting);
            ak_CitySelect.setting = setting;
            ak_CitySelect.target = $(e.target);
            ak_CitySelect.init();
            ak_CitySelect.container.css({
                'width': $(ak_CitySelect.setting.search_input).outerWidth(),
                'top': $(ak_CitySelect.setting.search_input).offset().top + $(ak_CitySelect.setting.search_input).outerHeight()-1,
                'left': $(ak_CitySelect.setting.search_input).offset().left
            }).slideToggle();
            ak_CitySelect.resultct.on('click', 'li', function() {
                ak_CitySelect.target.val($(this).find('.name').text());
                ak_CitySelect.triggleShow('all');
            });
        });
        return this;
    };
}(jQuery));

/*-----------------------------------------------Andrew_bigAutocomplete-------------------------------------------*/
(function($){
    var Andrew_bigAutocomplete = new function(){
        this.currentInputText = null;//目前获得光标的输入框（解决一个页面多个输入框绑定自动补全功能）
        this.functionalKeyArray = [9,20,13,16,17,18,91,92,93,45,36,33,34,35,37,39,112,113,114,115,116,117,118,119,120,121,122,123,144,19,145,40,38,27];//键盘上功能键键值数组
        this.holdText = null;//输入框中原始输入的内容
        var inputs = this;
        //初始化插入自动补全div，并在document注册mousedown，点击非div区域隐藏div
        this.init = function(){
            $('body').append("<div class='ak-bigautocomplete-layout'></div>");

            $(inputs).bind('mousedown',function(event){
                var $target = $(event.target);
                $(".ak-bigautocomplete-layout").slideToggle(1000);
                if((!($target.parents().andSelf().is('.ak-bigautocomplete-layout'))) && (!$target.is(currentInputText))){
                    Andrew_bigAutocomplete.hideAutocomplete();
                }
            });
            $(document).click(function(){
                Andrew_bigAutocomplete.hideAutocomplete();
            })
            //鼠标悬停时选中当前行
            $(".ak-bigautocomplete-layout").delegate("tr", "mouseover", function() {
                $(".ak-bigautocomplete-layout tr").removeClass("ct");
                $(this).addClass("ct");
            }).delegate("tr", "mouseout", function() {
                $(".ak-bigautocomplete-layout tr").removeClass("ct");
            });
            //单击选中行后，选中行内容设置到输入框中，并执行callback函数
            $(".ak-bigautocomplete-layout").delegate("tr", "click", function() {
                Andrew_bigAutocomplete.currentInputText.val( $(this).find("div:last").html());
                var callback_ = Andrew_bigAutocomplete.currentInputText.data("config").callback;
                if($(".ak-bigautocomplete-layout").css("display") != "none" && callback_ && $.isFunction(callback_)){
                    callback_($(this).data("jsonData"));
                }
                Andrew_bigAutocomplete.hideAutocomplete();
            })
        }
        this.autocomplete = function(param){
            if($("body").length > 0 && $(".ak-bigautocomplete-layout").length <= 0){
                Andrew_bigAutocomplete.init();//初始化信息
            }
            var $this = $(this);//为绑定自动补全功能的输入框jquery对象
            var $Andrew_bigAutocompleteContent = $(".ak-bigautocomplete-layout");
            this.config = {
                url:null,
                /*data：格式{data:[{autotext:null,result:{}},{autotext:null,result:{}}]}
                url和data参数只有一个生效，data优先*/
                data:null,
                //callback：选中行后按回车或单击时回调的函数
                callback:null};
            $.extend(this.config,param);
            $this.data("config",this.config);
            //输入框keydown事件
            $this.keydown(function(event) {
                switch (event.keyCode) {
                    case 40://向下键
                        if($Andrew_bigAutocompleteContent.css("display") == "none")return;
                        var $nextSiblingTr = $Andrew_bigAutocompleteContent.find(".ct");
                        if($nextSiblingTr.length <= 0){//没有选中行时，选中第一行
                            $nextSiblingTr = $Andrew_bigAutocompleteContent.find("tr:first");
                        }else{
                            $nextSiblingTr = $nextSiblingTr.next();
                        }
                        $Andrew_bigAutocompleteContent.find("tr").removeClass("ct");
                        if($nextSiblingTr.length > 0){//有下一行时（不是最后一行）
                            $nextSiblingTr.addClass("ct");//选中的行加背景
                            $this.val($nextSiblingTr.find("div:last").html());//选中行内容设置到输入框中
                            //div滚动到选中的行,jquery-1.6.1 $nextSiblingTr.offset().top 有bug，数值有问题
                            $Andrew_bigAutocompleteContent.scrollTop($nextSiblingTr[0].offsetTop - $Andrew_bigAutocompleteContent.height() + $nextSiblingTr.height() );
                        }else{
                            $this.val(Andrew_bigAutocomplete.holdText);//输入框显示用户原始输入的值
                        }
                        break;
                    case 38://向上键
                        if($Andrew_bigAutocompleteContent.css("display") == "none")return;

                        var $previousSiblingTr = $Andrew_bigAutocompleteContent.find(".ct");
                        if($previousSiblingTr.length <= 0){//没有选中行时，选中最后一行行
                            $previousSiblingTr = $Andrew_bigAutocompleteContent.find("tr:last");
                        }else{
                            $previousSiblingTr = $previousSiblingTr.prev();
                        }
                        $Andrew_bigAutocompleteContent.find("tr").removeClass("ct");
                        if($previousSiblingTr.length > 0){//有上一行时（不是第一行）
                            $previousSiblingTr.addClass("ct");//选中的行加背景
                            $this.val($previousSiblingTr.find("div:last").html());//选中行内容设置到输入框中
                            //div滚动到选中的行,jquery-1.6.1 $$previousSiblingTr.offset().top 有bug，数值有问题
                            $Andrew_bigAutocompleteContent.scrollTop($previousSiblingTr[0].offsetTop - $Andrew_bigAutocompleteContent.height() + $previousSiblingTr.height());
                        }else{
                            $this.val(Andrew_bigAutocomplete.holdText);//输入框显示用户原始输入的值
                        }
                        break;
                    case 27://ESC键隐藏下拉框
                        Andrew_bigAutocomplete.hideAutocomplete();
                        break;
                }
            });
            //输入框keyup事件
            $this.keyup(function(event) {
                var k = event.keyCode;
                var ctrl = event.ctrlKey;
                var isFunctionalKey = false;//按下的键是否是功能键
                for(var i=0;i<Andrew_bigAutocomplete.functionalKeyArray.length;i++){
                    if(k == Andrew_bigAutocomplete.functionalKeyArray[i]){
                        isFunctionalKey = true;
                        break;
                    }
                }
                //k键值不是功能键或是ctrl+c、ctrl+x时才触发自动补全功能
                if(!isFunctionalKey && (!ctrl || (ctrl && k == 67) || (ctrl && k == 88)) ){
                    var config = $this.data("config");
                    var offset = $this.offset();
                    $Andrew_bigAutocompleteContent.width($this.outerWidth()-2);
                    var h = $this.outerHeight() - 1;
                    $Andrew_bigAutocompleteContent.css({"top":offset.top + h,"left":offset.left});
                    var data = config.data;
                    var url = config.url;
                    var keyword_ = $.trim($this.val());
                    if(keyword_ == null || keyword_ == ""){
                        Andrew_bigAutocomplete.hideAutocomplete();
                        return;
                    }
                    if(data != null && $.isArray(data) ){
                        var data_ = new Array();
                        for(var i=0;i<data.length;i++){
                            if(data[i].autotext.indexOf(keyword_) > -1){
                                data_.push(data[i]);
                            }
                        }
                        makeContAndShow(data_);
                    }else if(url != null && url != ""){//ajax请求数据
                        $.post(url,{keyword:keyword_},function(result){
                            makeContAndShow(result.data)
                        },"json")
                    }
                    Andrew_bigAutocomplete.holdText = $this.val();
                }
                //回车键
                if(k == 13){
                    var callback_ = $this.data("config").callback;
                    if($Andrew_bigAutocompleteContent.css("display") != "none"){
                        if(callback_ && $.isFunction(callback_)){
                            callback_($Andrew_bigAutocompleteContent.find(".ct").data("jsonData"));
                        }
                        $Andrew_bigAutocompleteContent.hide();
                    }
                }
            });
            //组装下拉框html内容并显示
            function makeContAndShow(data_){
                if(data_ == null || data_.length <=0 ){
                    return;
                }
                var cont = "<table><tbody>";
                for(var i=0;i<data_.length;i++){
                    cont += "<tr><td><div>" + data_[i].autotext + "</div></td></tr>"
                }
                cont += "</tbody></table>";
                $Andrew_bigAutocompleteContent.html(cont);
                $Andrew_bigAutocompleteContent.slideDown();
                //每行tr绑定数据，返回给回调函数
                $Andrew_bigAutocompleteContent.find("tr").each(function(index){
                    $(this).data("jsonData",data_[index]);
                })
            }
            //输入框focus事件
            $this.focus(function(){
                Andrew_bigAutocomplete.currentInputText = $this;
            });
        };
        //隐藏下拉框
        this.hideAutocomplete = function(){
            var $Andrew_bigAutocompleteContent = $(".ak-bigautocomplete-layout");
            if($Andrew_bigAutocompleteContent.css("display") != "none"){
                $Andrew_bigAutocompleteContent.find("tr").removeClass("ct");
                $Andrew_bigAutocompleteContent.slideUp();
            }
        }
    };
    $.fn.Andrew_bigAutocomplete = Andrew_bigAutocomplete.autocomplete;
}(jQuery));

/*-----------------------------------------------Andrew_MinAutoCompleter-------------------------------------------*/
(function($){
    var h = $(window),
        o = $(document),
        n = function(a, d) {
            this.$element = $(a),
                this.defaults = $.extend({},
                    n.defaults, this.$element.data(), $.isPlainObject(d) ? d: {}),
                this.init()
        },
        m = function(b) {
            return "string" == typeof b && "" !== b ? (b = l(b), new RegExp(b + "+[^" + b + "]*$", "i")) : null
        },
        l = function(b) {
            return b.replace(/([\.\$\^\{\[\(\|\)\*\+\?\\])/g, "\\$1")
        },
        k = function(a) {
            return "string" == typeof a && (a = a.replace(/[\{\}\[\]"']+/g, "").split(/\s*,+\s*/)),
                a = $.map(a,
                    function(b) {
                        return "string" != typeof b ? b.toString() : b
                    })
        };
    n.prototype = {
        constructor: n,
        init: function() {
            var a = this.defaults,
                d = k(a.source);
            d.length > 0 && (this.data = d, this.regexp = m(a.separator), this.$Andrew_MinAutoCompleter = $(a.template), this.$Andrew_MinAutoCompleter.hide(), this.$element.attr("autocomplete", "off").on({
                focus: $.proxy(this.enable, this),
                blur: $.proxy(this.disable, this)
            }), this.$element.is(":focus") && this.enable())
        },
        enable: function() {
            this.active || (this.active = !0, this.$element.on({
                keydown: $.proxy(this.keydown, this),
                keyup: $.proxy(this.keyup, this)
            }), this.$Andrew_MinAutoCompleter.on({
                mousedown: $.proxy(this.mousedown, this),
                mouseover: $.proxy(this.mouseover, this)
            }))
        },
        disable: function() {
            this.active && (this.active = !1, this.$element.off({
                keydown: this.keydown,
                keyup: this.keyup
            }), this.$Andrew_MinAutoCompleter.off({
                mousedown: this.mousedown,
                mouseover: this.mouseover
            }))
        },
        attach: function(v) {
            var u, t, s = this.defaults.separator,
                r = this.regexp,
                q = r ? v.match(r) : null,
                p = [],
                f = [],
                a = this;
            q && (q = q[0], v = v.replace(r, ""), u = new RegExp("^" + l(q), "i")),
                $.each(this.data,
                    function(b, c) {
                        c = s + c,
                            t = a.template(v + c),
                            u && u.test(c) ? p.push(t) : f.push(t)
                    }),
                p = p.length ? p.sort() : f,
            "top" === this.defaults.position && (p = p.reverse()),
                this.fill(p.join(""))
        },
        suggest: function(a) {
            var p = new RegExp(l(a), "i"),
                g = this,
                f = [];
            $.each(this.data,
                function(d, c) {
                    p.test(c) && f.push(c)
                }),
                f.sort(function(b, d) {
                    return b.indexOf(a) - d.indexOf(a)
                }),
                $.each(f,
                    function(d, c) {
                        f[d] = g.template(c)
                    }),
                this.fill(f.join(""))
        },
        template: function(d) {
            var c = this.defaults.itemTag;
            return "<" + c + ">" + d + "</" + c + ">"
        },
        fill: function(d) {
            var c;
            this.$Andrew_MinAutoCompleter.empty(),
                d ? (c = "top" === this.defaults.position ? ":last": ":first", this.$Andrew_MinAutoCompleter.html(d), this.$Andrew_MinAutoCompleter.children(c).addClass(this.defaults.selectedClass), this.show()) : this.hide()
        },
        complete: function() {
            var d = this.defaults,
                c = d.filter(this.$element.val()).toString();
            $("body").append(this.$Andrew_MinAutoCompleter);
            this.place();
            return "" === c ? void this.hide() : void(d.suggest ? this.suggest(c) : this.attach(c))
        },
        keydown: function(b) {
            13 === b.keyCode && (b.stopPropagation(), b.preventDefault())
        },
        keyup: function(d) {
            var c = d.keyCode;
            13 === c || 38 === c || 40 === c ? this.toggle(c) : this.complete()
        },
        mouseover: function(a) {
            var p = this.defaults,
                g = p.selectedClass,
                f = $(a.target);
            f.is(p.itemTag) && f.addClass(g).siblings().removeClass(g)
        },
        mousedown: function(a) {
            a.stopPropagation(),
                a.preventDefault(),
                this.setValue($(a.target).text())
        },
        setValue: function(b) {
            this.$element.val(b),
                this.defaults.complete(),
                this.hide()
        },
        toggle: function(e) {
            var d = this.defaults.selectedClass,
                f = this.$Andrew_MinAutoCompleter.find("." + d);
            switch (e) {
                case 40:
                    f.removeClass(d),
                        f = f.next();
                    break;
                case 38:
                    f.removeClass(d),
                        f = f.prev();
                    break;
                case 13:
                    this.setValue(f.text())
            }
            0 === f.length && (f = this.$Andrew_MinAutoCompleter.children(40 === e ? ":first": ":last")),
                f.addClass(d)
        },
        place: function() {
            var b = this.$element,
                u = b.offset(),
                t = u.left,
                s = u.top,
                r = b.outerHeight(),
                q = b.outerWidth(),
                p = {
                    minWidth: q,
                    zIndex: this.defaults.zIndex
                };
            switch (this.defaults.position) {
                case "right":
                    p.left = t + q,
                        p.top = s;
                    break;
                case "left":
                    p.right = h.innerWidth() - t,
                        p.top = s;
                    break;
                case "top":
                    p.left = t,
                        p.bottom = h.innerHeight() - s;
                    break;
                default:
                    p.left = t,
                        p.top = s + r
            }
            this.$Andrew_MinAutoCompleter.css(p)
        },
        show: function() {
            this.$Andrew_MinAutoCompleter.slideDown(),
                h.on("resize", $.proxy(this.place, this)),
                o.on("mousedown", $.proxy(this.hide, this))
        },
        hide: function() {
            this.$Andrew_MinAutoCompleter.slideUp(),
                h.off("resize", this.place),
                o.off("mousedown", this.hide)
        },
        destroy: function() {
            this.hide(),
                this.disable(),
                this.$element.off({
                    focus: this.enable,
                    blur: this.disable
                })
        }
    },
        n.defaults = {
            itemTag: "li",
            position: "bottom",
            source: [],
            selectedClass: "ak-MinAutoCompleter-selected",
            separator: "",
            suggest: !1,
            template: '<ul class="ak-MinAutoCompleter-container"></ul>',
            zIndex: 5,
            complete: $.noop,
            filter: function(b) {
                return b
            }
        },
        n.setDefaults = function(a) {
            $.extend(n.defaults, a)
        },
        $.fn.Andrew_MinAutoCompleter = function(a) {
            var f, d = [].slice.call(arguments, 1);
            return this.each(function() {
                var e, c = $(this),
                    b = c.data("Andrew_MinAutoCompleter");
                b || c.data("Andrew_MinAutoCompleter", b = new n(this, a)),
                "string" == typeof a && $.isFunction(e = b[a]) && (f = e.apply(b, d))
            }),
                "undefined" != typeof f ? f: this
        },
        $.fn.Andrew_MinAutoCompleter.Constructor = n,
        $.fn.Andrew_MinAutoCompleter.setDefaults = n.setDefaults,
        $(function() {
            $('[data-toggle="Andrew_MinAutoCompleter"],[Andrew_MinAutoCompleter]').Andrew_MinAutoCompleter()
        })
}(jQuery));

/*-----------------------------------------------Andrew_ChangeIcon-------------------------------------------*/
(function($){
    $.fn.Andrew_ChangeIcon = function(setting) {
        var option = $.extend({
                Element: setting.Element || "",
                Default_icon: setting.Element || "",
                Change_icon: setting.Element || "",
                body_close: false,
                clickBack: function () {
                }
            },
            setting);
        var $ChangeIcon = $(this);
        $ChangeIcon.each(function () {
            $(option.Element).addClass(option.Default_icon);
            $ChangeIcon.click(function () {
                $(option.Element).toggleClass(option.Change_icon + " " + option.Default_icon);
                if ($(option.Element).hasClass(option.Change_icon)) {
                    //$(option.Element).removeClass(option.Default_icon).addClass(option.Change_icon);
                    option.clickBack(1)
                } else {
                    //$(option.Element).removeClass(option.Change_icon).addClass(option.Default_icon);
                    option.clickBack(0)
                }
            });
        });
        if (option.body_close == true) {
            $("body").click(function () {
                $(option.Element).removeClass(option.Change_icon).addClass(option.Default_icon);
            });
        }
    };
}(jQuery));

/*-----------------------------------------------Andrew_ChangeInput-------------------------------------------*/
(function($){
    $.fn.Andrew_ChangeInput = function(setting) {
        var option = $.extend({
                left_input: "", //切换按钮的左侧输入框Class
                right_input: "", //切换按钮的右侧输入框Class
            },
            setting);
        var $ChangeInput = $(this);
        $ChangeInput.click(function() {
            var left_input = $(option.left_input);
            var right_input = $(option.right_input);
            var tmp ="";
            var left_input_value = left_input.val();
            var right_input_value = right_input.val();
            tmp = left_input_value;
            left_input.val(right_input_value);
            right_input.val(tmp);
        });
    };
}(jQuery));

/*-----------------------------------------------Andrew_ButtonChange-------------------------------------------*/
(function($){
    $.fn.Andrew_ButtonChange = function(setting) {
        var option = $.extend({
                onoff:0,
                Default_Class: setting.Element || "",
                Change_Class: setting.Element || "",
                clickBack:function(){
                }
            },
            setting);
        var $ButtonChange = $(this);
        $ButtonChange.each(function(){
            $(this).addClass(option.Default_Class);
            $(this).attr("data-default",$(this).text());
        });
        $ButtonChange.click(function() {
            $(this).toggleClass(option.Change_Class+" "+option.Default_Class);
            if ($(this).hasClass(option.Change_Class)) {
                $(this).text($(this).attr("data-toggle"));
                option.onoff = 1;
            } else {
                $(this).text($(this).attr("data-default"));
                option.onoff = 0;
            }
            option.clickBack(option.onoff,$(this));
        });
    };
}(jQuery));

/*-----------------------------------------------Andrew_SearchChoose-------------------------------------------*/
(function($){
    $.fn.Andrew_SearchChoose = function(setting) {
        var option = $.extend({
                search_input: "",
                more_btn: "MORE",
                popup_class: "bg_black07 pa_1em",
                searchList:[],
                callback:function(){},
                moreback:function(){}
            },
            setting);
        var $SearchChoose = this;
        $SearchChoose.on('click', function(e){
            e.stopPropagation();
            if ($(".ak-SearchChoose-wrapper").length < 1) {
                $("body").append("<div class=\"ak-SearchChoose-wrapper\">\n" +
                    "    <ul class=\"ak-SearchChoose-nav bor_bottom bor_gray_ddd\"></ul>\n" +
                    "    <ol class=\"ak-SearchChoose-content\"></ol>\n" +
                    "    <div class=\"ak-SearchChoose-bottom\">\n" +
                    "    </div>\n" +
                    "  </div>");
            }
            var search_in = option.search_input.substring(1,option.search_input.length);
            $(".ak-SearchChoose-wrapper").attr("id",search_in+"_popupwin");

            var popupwin = $("#"+search_in+"_popupwin");

            popupwin.addClass(option.popup_class);
            popupwin.css({
                "width": $(option.search_input).outerWidth(),
                "position": "absolute",
                "top": $(option.search_input).offset().top + $(option.search_input).innerHeight(),
                "left": $(option.search_input).offset().left
            });
            if (popupwin.length <= 1 ) {
                popupwin.slideToggle();
            } else {
                popupwin.slideUp();
                setTimeout(function() {
                        popupwin.remove();
                    },
                    500);
            }
            popupwin.find(".ak-SearchChoose-bottom").html("<a href='"+option.more_url+"' class='c_title'>"+option.more_btn+"</a>");
            //原先的Tabs名称列表清空
            popupwin.find('.ak-SearchChoose-nav').html('');
            if(typeof(option.searchList)!=='undefined'){
                if(""!=option.searchList && null!=option.searchList && option.searchList.length>0){
                    for(i=0;i<option.searchList.length;i++){
                        popupwin.find('.ak-SearchChoose-nav').append('<li class="SearchTabs-item" SearchTabs-id="'+option.searchList[i].id+'">'+option.searchList[i].name+'</li>');
                    }
                    //默认情况下, 给第一个Tabs名称添加SearchChoosen样式
                    popupwin.find('[SearchTabs-id="1"]').addClass('bg_title c_white');
                }
            }

            //添加Tabs名称列表项的click事件
            popupwin.find('.SearchTabs-item').bind('click',function(){
                var item=$(this);
                var SearchTabs = item.attr('SearchTabs-id');
                var SearchChoosenItem = item.parent().find('.bg_title');
                if(SearchChoosenItem)
                    $(SearchChoosenItem).removeClass('bg_title c_white');
                item.addClass('bg_title c_white');
                //更新数据列表
                initSearch(SearchTabs);
            });
            popupwin.on('click', function(e) {
                e.stopPropagation();
                $(this).show();
            });
            $("body").on('click', function(e) {
                e.stopPropagation();
                popupwin.slideUp();
                setTimeout(function() {
                        popupwin.remove();
                    },
                    500);
            });
            //初始化数据列表
            initSearch(1);
        });
        function initSearch(SearchTabsID){
            var search_ins = option.search_input.substring(1,option.search_input.length);
            $(".ak-SearchChoose-wrapper").attr("id",search_ins+"_popupwin");

            var popupwin_init = $("#"+search_ins+"_popupwin");
            //原先的数据列表清空
            popupwin_init.find('.ak-SearchChoose-content').html('');
            if(typeof(option.searchList)!=='undefined'){
                if(""!=option.searchList && null!=option.searchList && option.searchList.length>0){
                    var searchs = option.searchList[SearchTabsID-1].search;
                    for(i=0;i<searchs.length;i++){
                        popupwin_init.find('.ak-SearchChoose-content').append('<li class="search-item" search-id="'+searchs[i].id+'">'+searchs[i].name+'</li>');
                    }
                }
            }
            //添加数据列表项的click事件
            popupwin_init.find('.search-item').bind('click', function(){
                var item=$(this);
                var search = item.attr('search-id');

                //更新选择数据文本框中的值
                $(option.search_input).val(item.text());

                //关闭弹窗
                popupwin_init.slideUp();
                setTimeout(function() {
                        popupwin_init.remove();
                    },
                    500);
                var obj = {};
                obj.id = search;
                obj.name = item.text();
                option.callback(obj);
            });
            popupwin_init.find('.ak-SearchChoose-bottom a').bind('click', function(){
                var ele=$(this);
                option.moreback(ele);
            });
            popupwin_init.find('.ak-SearchChoose-bottom button').bind('click', function(){
                //关闭弹窗
                popupwin_init.slideUp();
                setTimeout(function() {
                        popupwin_init.remove();
                    },
                    500);
            });
        }
    };
}(jQuery));

/*-----------------------------------------------Andrew_NavMenu-------------------------------------------*/
(function($){
    $.fn.Andrew_NavMenu = function(setting) {
        var option = $.extend({
                LinePosition: "bottom",
                LineHeight: "0.3em",
            },
            setting);
        if (this.length > 0) {
            var $navBox = this,
                $liCur = $navBox.find("li.c_title"),
                curP = $liCur.position().left,
                curW = $liCur.outerWidth(true),
                $slider = $navBox.children("abbr");
            $targetEle = $navBox.find("li a"),
                $slider.addClass("dis_block bg_title abs").animate({
                    "left": curP,
                    "width": curW
                });
            switch (option.LinePosition) {
                case 'bottom':
                    $slider.css({
                        "bottom": '0',
                        "height": option.LineHeight
                    });
                    break;
                case 'top':
                    $slider.css({
                        "top": '0',
                        "height": option.LineHeight
                    });
                    break;
            }
            $targetEle.mouseenter(function () {
                var $_parent = $(this).parent(),
                    _width = $_parent.outerWidth(true),
                    posL = $_parent.position().left;
                $slider.stop(true, true).animate({
                    "left": posL,
                    "width": _width
                }, "fast");
            });
            $navBox.mouseleave(function (cur, wid) {
                cur = curP;
                wid = curW;
                $slider.stop(true, true).animate({
                    "left": cur,
                    "width": wid
                }, "fast");
            });
        }
    };
}(jQuery));

/*-----------------------------------------------Andrew_ImgSubject-------------------------------------------*/
(function($){
    $.fn.Andrew_ImgSubject = function(setting) {
        var option = $.extend({
                delay: 400,
                height: "6em",
            },
            setting);
        var imgsubject = $(this);
        imgsubject.hover(function(){
            $(this).find("div").stop().animate({
                height:"100%"
            },option.delay);
            $(this).find("div h6").stop().animate({
                paddingTop:option.height
            },option.delay);
        },function(){
            $(this).find("div").stop().animate({
                height:option.height
            },option.delay);
            $(this).find("div h6").stop().animate({
                paddingTop:"0"
            },option.delay);
        });
        imgsubject.each(function(){
            $(this).find("div").css({
                'height': option.height
            });
        });
    };
}(jQuery));

/*-----------------------------------------------Andrew_Slider-------------------------------------------*/
/*-----------------------------------------------Andrew_Slider-------------------------------------------*/
(function($){
    var Andrew_Slider = function(element, options){
        this.width = undefined,
            this.height = undefined,
            this.parent_width = undefined,
            this.num_slides = 0;
        this.current_slide = undefined;
        this.$sliders = undefined;
        this.$very_current_slide = undefined; //This is very close current slide, it is the one before transitioning, and the moment when user click 'next', 'prev' or 'navigations'.
        this.is_pause = false;
        this.play_timer = true;
        this.active_timer = false;
        this.on_transition = false;
        this._$progress_bar = undefined;
        this.all_transitions = ['slide-left', 'slide-right', 'slide-top', 'slide-bottom', 'fade', 'split', 'split3d', 'door', 'wave-left', 'wave-right', 'wave-top', 'wave-bottom'];
        this.requestFrame = window.requestAnimationFrame ||
            window.webkitRequestAnimationFrame ||
            window.mozRequestAnimationFrame ||
            window.oRequestAnimationFrame ||
            window.msRequestAnimationFrame ||
            function (callback) {
                return window.setTimeout(callback, 1000 / 60);
            };
        this.options = {
            width: undefined, //initial width, automaticall ycalculated once the first image is loaded
            height: undefined, //initial height, automatically calculated once the first image is loaded
            userCSS: false, //if this is true, 'Previous, Next Buttons and Navigation CSS' will not be applied. User should define CSS in their css file.
            transitionSpeed: 1000,
            duration: 4000,
            showNavigation: false,
            classNavigation: false,
            navigationColor: '#9F1F22',
            navigationHoverColor: '#D52B2F',
            navigationHighlightColor: '#DFDFDF',
            navigationNumberColor: '#000000',
            positionNavigation: 'out-center-bottom',
            // 'out-center-bottom', 'out-left-bottom', 'out-right-bottom', 'out-center-top', 'out-left-top', 'out-right-top',
            // 'in-center-bottom', 'in-left-bottom', 'in-right-bottom', 'in-center-top', 'in-left-top', 'in-right-top',
            // 'in-left-middle', 'in-right-middle'
            navigationType: 'circle', // number, circle, square
            showControl: true,
            classButtonNext: undefined,
            classButtonPrevious: undefined,
            controlColor: '#FFFFFF',
            controlBackgroundColor: '#000000',
            positionControl: 'left-right', // 'left-right', 'top-center', 'bottom-center', 'top-left', 'top-right', 'bottom-left', 'bottom-right'
            transition: 'slide-left', //random, slide-left, slide-right, slide-top, slide-bottom, fade, split, split3d, door, wave-left, wave-right, wave-top, wave-bottom
            transitionExt:'slide-right',
            showProgress: false,
            progressColor: '#797979',
            pauseOnHover: true,
            onReady: undefined

        };
        $.extend(this.options, options);
        this.$ele = $(element);
        this.$ele.wrapInner('<div class="inner ak-slider"><div class="projector"></div></div>');
        this.$ele_in = this.$ele.children('.inner:first');
        this.$ele_projector = this.$ele_in.children('.projector:first');
    };
    Andrew_Slider.prototype = {
        _init: function(){
            var that = this;
            this._stopTimer(function(){
                that._prepare(function(){
                    if(typeof that.options.onReady == 'function') that.options.onReady();
                    that._playSlide();
                    $(window).on('resize.Andrew_Slider', function(){
                        that._resize();
                    });
                });
            });
            if(this.options.pauseOnHover){
                this.$ele_in.on('mouseenter', function(){
                    that.is_pause = true;
                    that._showButtons();
                });
                this.$ele_in.on('mouseleave', function(){
                    that.is_pause = false;
                    that._hideButtons();
                });
            }
        },
        _getEndEvent: function(prop){
            var vendors = 'webkit Moz Ms o Khtml'.split(' ');
            var len = vendors.length;
            if (prop in document.body.style) return prop+'end';
            prop = prop.charAt(0).toUpperCase() + prop.slice(1);
            for(var i =0; i<vendors.length; i++){
                if(vendors[i]+prop in document.body.style) return vendors[i]+prop+'End';
            }
            return false;
        },
        _animate: function(selector, from, to, duration, delay, callback, jQueryAnimation){
            var $obj;
            if(!delay) delay = 0;
            if(selector instanceof jQuery) $obj = selector;
            else $obj = $(selector);
            if($obj.length == 0){
                if(typeof callback == 'function') {
                    setTimeout(function(){
                        callback();
                    }, delay);
                }
                return;
            }
            if(typeof duration != 'number') duration = 0;
            if(typeof delay != 'number') delay = 0;
            var event_end;
            if(jQueryAnimation) event_end = false;
            else event_end = this._getEndEvent('transition');
            if(event_end !== false){
                var from_delay = 0;
                if(from) {
                    $obj.css(from);
                    from_delay = 30;
                }
                setTimeout(function(){
                    var transition = {
                        '-webkit-transition': 'all '+duration+'ms ease '+delay+'ms',
                        '-moz-transition': 'all '+duration+'ms ease '+delay+'ms',
                        '-o-transition': 'all '+duration+'ms ease '+delay+'ms',
                        'transition': 'all '+duration+'ms ease '+delay+'ms'
                    }
                    var css = $.extend({}, transition, to);
                    $obj.css(css);
                    var fired = false; //to ensure it fires event only once
                    $obj.one(event_end, function(){
                        $obj.css({
                            '-webkit-transition': '',
                            '-moz-transition': '',
                            '-o-transition': '',
                            'transition': ''
                        });
                        if(typeof callback == 'function') callback();
                    });
                }, from_delay);
            }
            else {
                setTimeout(function(){
                    if(from) $obj.css(from);
                    $obj.animate(to, duration, function(){
                        callback();
                    });
                }, delay);
            }
        },
        _prepare: function(callback){
            var that = this;
            this.parent_width = this.$ele.parent().width();
            this.$ele.css({
                'visibility': 'hidden',
                'width': 'auto',
                'height': 'auto',
                'min-height': this.options.height
            });
            this.$ele_in.css({
                'position': 'relative',
                'margin': '0 auto'
            });
            this.$ele_projector.css({
                'position': 'relative',
                'overflow': 'hidden'
            });
            /*
             * set CSS for init
             * Only the first child will be shown at start, hiding others.
             */
            var $sliders = this.$ele_projector.children('[class!=slider-progress]');
            $sliders.css({
                'display': 'none',
                'position': 'absolute',
                'top': '0',
                'left': '0'
            });
            this.$sliders = $sliders;
            this.num_slides = this.$sliders.length;
            //preload images sequentially so that images are not loaded slide by slide.
            var arr_all_images = [];
            this.$ele_projector.find('[data-lazy-src], [data-lazy-background]').each(function(){
                var image = $(this).data('lazy-src') || $(this).data('lazy-background');
                arr_all_images.push(image);
            });
            this._preloadImages(arr_all_images, function(){ });
            /*
             * There are 3 possibilities.
             * 1[image]
             *    <img data-lazy-src data-transition/>
             * 2[link]
             *    <a data-lazy-src data-transition><img/></a>
             * 3[animation]
             *    <div data-transition data-background>
             * 		<img data-lazy-src data-start-pos data-end-pos data-duration data-easing />
             * 		<img data-lazy-src data-start-pos data-end-pos data-duration data-easing />
             *    </div>
             *
             * Now, we gotta decide what the case is.
             */
            this.$sliders.each(function(){
                $(this).find("span").removeAttr("style");
                var transparent_data = '';
                if(!$(this).hasClass('slider-progress') && !$(this).hasClass('button-slider')){
                    var images = [];
                    var has_main_image = true;
                    if($(this).data('lazy-background')){
                        $(this).addClass('primary-img background');
                        images.push($(this).data('lazy-background'));
                    }
                    else if($(this).data('lazy-src')) {
                        $(this).addClass('primary-img image');
                        $(this).css('vertical-align', 'bottom'); //to fix extra space problem inside a link.
                        $(this).attr('src', transparent_data);
                        images.push($(this).data('lazy-src'));
                    }
                    //such as <a><img></a> <div><img></div>, push a image below, so we do not push it into array
                    else if($(this).children().length == 1 && $(this).children('img').length == 1){
                        $(this).children('img[data-lazy-src]:first').addClass('primary-img image');
                    }
                    else {
                        has_main_image = false;
                    }
                    $(this).find('[data-lazy-src]').each(function(){
                        $(this).css('vertical-align', 'bottom'); //to fix extra space problem inside a link.
                        $(this).attr('src', transparent_data);
                        images.push($(this).data('lazy-src'));
                    });
                    $(this).find('[data-lazy-background]').each(function(){
                        images.push($(this).data('lazy-background'));
                    });
                    $(this).data({'has-main-image': has_main_image,'images': images});
                    $(this).children('[data-pos]').css('display', 'none');
                }
            });
            //if initial width and height are defined, this sets the box width and height before loading images.
            if(this.options.width && this.options.height){
                var obj = {
                    width: this.options.width,
                    height: this.options.height
                };
                this.width = obj.width;
                this.height = obj.height;
                this.$ele_in.css(obj);
                this.$ele_projector.css(obj);
                //show Controls
                if(that.num_slides > 1 && that.options.showControl) that._attachControl();
                //show Navigation
                if(that.num_slides > 1 && that.options.showNavigation) that._attachNavigation();
                if(that.options.classNavigation) that._attachUserNavigation();
                if(that.options.classButtonPrevious || that.options.classButtonNext) that._attachUserControlEvent();
                callback();
            }
            else {
                /*
                 * load first image and set the box dimension as the image size
                 */
                var first_img = new Image();
                first_img.onload = first_img.onerror = function(){
                    var obj = {
                        width: first_img.width,
                        height: first_img.height
                    };
                    that.width = obj.width;
                    that.height = obj.height;
                    that.$ele_in.css(obj);
                    that.$ele_projector.css(obj);
                    //show Controls
                    if(that.num_slides > 1 && that.options.showControl) that._attachControl();
                    //show Navigation
                    if(that.num_slides > 1 && that.options.showNavigation) that._attachNavigation();
                    if(that.options.classNavigation) that._attachUserNavigation();
                    if(that.options.classButtonPrevious || that.options.classButtonNext) that._attachUserControlEvent();
                    callback();
                }
                first_img.src = this.$sliders.first().data('images')[0];
            }
        },
        _resetSize: function($element, new_width, new_height, callback){
            var new_size = {
                width: new_width,
                height: new_height
            };
            var $target1, $target2;
            if($element) {
                $target1 = $element;
                $target2 = $element.find('.primary-img:first');
                $prev_target1 = this.$ele_projector.children('.ak-is_active.primary-img:first');
                $prev_target2 = this.$ele_projector.children('.ak-is_active').find('.primary-img:first');
            }
            else {
                $target1 = this.$ele_projector.children('.ak-is_active');
                $target2 = this.$ele_projector.children('.ak-is_active').find('.primary-img:first');
            }
            $target1.css(new_size);
            $target2.css(new_size);
            if($element){
                /*
                 * When the size of next slide is different from the current one,
                 * We animate the box size.
                 */
                if(this.width != new_width || this.height != new_height){
                    $prev_target1.animate(new_size);
                    $prev_target2.animate(new_size);
                    this.$ele_in.css(new_size); //.animate() makes this block 'overflow: hidden', so I use just .css().
                    this.$ele_projector.animate(new_size, function(){
                        if(typeof callback == 'function') callback();
                    });
                }
                else {
                    if(typeof callback == 'function') callback();
                }
            }
            //This is the case when the window size is resized by the user.
            else {
                if(this.on_transition == true){
                    this.$very_current_slide.css({
                        'display': 'block',
                        'top': '0',
                        'left': '0',
                        'z-index': '5',
                        'width': new_width,
                        'height': new_height
                    });
                }
                this.$ele_in.css(new_size);
                this.$ele_projector.css(new_size);
                if(typeof callback == 'function') callback();
            }
            this.width = new_width;
            this.height = new_height;
        },
        _resize: function($element, callback){
            var that = this;
            this.parent_width = this.$ele.parent().width();
            var new_width, new_height, original;
            if(this.options.width && this.options.height){
                original = {
                    'width': this.options.width,
                    'height': this.options.height
                };
            }
            else if(!$element) original = this.$ele_projector.children('.ak-is_active').data('original');
            else original = $element.data('original');

            new_width = original.width;
            new_height = original.height;
            this._resetSize($element, new_width, new_height, callback);
        },
        _attachUserControlEvent: function(){
            var that = this;
            if(this.options.classButtonPrevious){
                $('.'+this.options.classButtonPrevious).unbind("click");
                $('.'+this.options.classButtonPrevious).on('click', function(e){
                    e && e.preventDefault();
                    if(that.play_timer == false || that.on_transition == true) return;
                    that._stopTimer(function(){
                        that._startTimer(function(){
                            that._prev();
                        });
                    });
                });
            }
            if(this.options.classButtonNext){
                $('.'+this.options.classButtonNext).unbind("click");
                $('.'+this.options.classButtonNext).on('click', function(e){
                    e && e.preventDefault();
                    if(that.play_timer == false || that.on_transition == true) return;
                    that._stopTimer(function(){
                        that._startTimer(function(){
                            that._next();
                        });
                    });
                });
            }
        },
        _attachUserNavigation: function(){
            var that = this;
            var $userNavigation = $('.'+this.options.classNavigation).find('[data-index]');
            if($userNavigation.length ==  0){
                $userNavigation = $('.'+this.options.classNavigation).children();
            }
            $userNavigation.unbind("click");
            $userNavigation.on('click', function(e){
                e && e.preventDefault();
                if(that.play_timer == false || that.on_transition == true) return;
                $userNavigation.removeClass('ak-is_active');
                $(this).addClass('ak-is_active');
                var navigation_num;
                if($(this).data('index') && $(this).data('index') != ''){
                    var slide_num = that.$ele_projector.children('[data-index=\''+$(this).data('index')+'\']').index();
                    if(slide_num > 0) navigation_num = slide_num;
                    else navigation_num = $(this).data('index');
                }
                else {
                    navigation_num = $(this).index();
                }
                if(navigation_num == that.current_slide) return;
                if(that.play_timer == false || that.on_transition == true) return;
                that._stopTimer(function(){
                    if(navigation_num > 0) that.current_slide = navigation_num - 1;
                    else that.current_slide = that.num_slides - 1;
                    that._startTimer(function(){
                        that._next();
                    });
                });
            });
        },
        _updateNavigation: function(){
            var that = this;
            if(this.options.classNavigation) {
                $('.'+this.options.classNavigation).find('.ak-is_active').removeClass('ak-is_active');
                var user_index = this.$sliders.eq(this.current_slide).data('index');

                if(typeof user_index != 'undefined' && user_index != ''){
                    $('.'+this.options.classNavigation).find('[data-index=\''+user_index+'\']').addClass('ak-is_active');
                }
                else {
                    var nav_index = $('.'+this.options.classNavigation).children().eq(this.current_slide).data('index');
                    if(!nav_index || nav_index == '')
                        $('.'+this.options.classNavigation).children().eq(this.current_slide).addClass('ak-is_active');
                }
            }
            this.$ele_projector.next('.navigation').find('.nav-link').removeClass('ak-is_active');
            this.$ele_projector.next('.navigation').find('.nav-link.index'+this.current_slide).addClass('ak-is_active');
            if(!this.options.userCSS){
                this.$ele_projector.next('.navigation').find('.nav-link').css({
                    'background-color': this.options.navigationColor
                });
                this.$ele_projector.next('.navigation').find('.nav-link.index'+this.current_slide).css({
                    'background-color': this.options.navigationHighlightColor
                });
            }
        },
        _attachNavigation: function(){
            if(this.num_slides < 2) return;
            var that = this;
            var navigation_html = '';
            for(var i =0; i < this.num_slides; i++)
                navigation_html += '<span class="nav-link index'+i+'" data-num="'+i+'">'+(i+1)+'</span>';
            this.$ele_projector.after('<div class="navigation ak-slider"><div class="inner">'+navigation_html+'</div></div>');
            var pos_nav = this.options.positionNavigation;
            var $navigation = this.$ele_projector.next('.navigation');
            var $nav_link = $navigation.find('.nav-link');
            $navigation.css({
                'font-size': '12px',
                'z-index': '3',
                'user-select': 'none'
            });
            if(!this.options.userCSS){
                $nav_link.css({
                    'display': 'inline-block',
                    'width' :  this.options.navigationType != 'number' ? '0.8em': '',
                    'height' :  this.options.navigationType != 'number' ? '0.8em': '',
                    'padding': '0.2em',
                    'font-size': '12px',
                    'cursor': 'pointer',
                    'vertical-align': 'bottom',
                    'color': this.options.navigationNumberColor,
                    'text-align': 'center',
                    'text-indent': this.options.navigationType != 'number' ? '-10000em' : '',
                    'width': this.options.navigationType == 'number' ? $nav_link.innerHeight()+'px' : '0.8em',
                    'border': '0px solid transparent',
                    'border-radius': this.options.navigationType == 'circle' ? '50%' : '',
                    'margin-top': (pos_nav == 'in-left-middle' || pos_nav == 'in-right-middle') ? '5px':'',
                    'margin-left': (pos_nav != 'in-left-middle' && pos_nav != 'in-right-middle') ? '5px':''
                });
                $navigation.find('.nav-link:first').css({
                    'margin-top': '0',
                    'margin-left': '0'
                });
                $navigation.find('.nav-link:last').css({
                    'margin-bottom': '0',
                    'margin-right': '0'
                });
                if(this.options.positionNavigation == 'in-left-middle'
                    || this.options.positionNavigation == 'in-right-middle'){

                    $navigation.children('.inner').css({
                        'width': $nav_link.outerWidth(true)+'px'
                    });
                }
                else {
                    var inner_width = 0;
                    $nav_link.each(function(){
                        inner_width += $(this).outerWidth(true);
                    });
                    $navigation.children('.inner').css({
                        'width': inner_width+'px'
                    });
                }
                // 'out-center-bottom', 'out-left-bottom', 'out-right-bottom', 'out-center-top', 'out-left-top', 'out-right-top',
                // 'in-center-bottom', 'in-left-bottom', 'in-right-bottom', 'in-center-top', 'in-left-top', 'in-right-top',
                // 'in-left-middle', 'in-right-middle'
                var nav_css_additional = {};
                var nav_height = $navigation.outerHeight();
                //vertical position
                switch(this.options.positionNavigation){
                    case 'out-center-top':
                    case 'out-left-top':
                    case 'out-right-top':
                        $navigation.css('margin', '-40px 0');
                        this.$ele.css('padding-top', (nav_height+10)+'px'); // 10 is 5+5 margin
                        nav_css_additional['top'] = (-1*(nav_height+10))+'px'; // 10 is 5+5 margin
                        break;
                    case 'out-center-bottom':
                    case 'out-left-bottom':
                    case 'out-right-bottom':
                        nav_css_additional['top'] = '100%';
                        $navigation.css('margin', '-40px 0');
                        //this.$ele.css('padding-bottom', (nav_height+10)+'px'); // 10 is 5+5 margin
                        break;
                    case 'in-center-top':
                    case 'in-left-top':
                    case 'in-right-top':
                        nav_css_additional['top'] = '20px';
                        break;
                    case 'in-center-bottom':
                    case 'in-left-bottom':
                    case 'in-right-bottom':
                    case 'out-right-bottom':
                        nav_css_additional['bottom'] = '20px';
                        break;
                    case 'in-left-middle':
                    case 'in-right-middle':
                        nav_css_additional['top'] = '50%';
                        nav_css_additional['margin-top'] = (-1*nav_height/2)+'px';
                        break;
                }
                //horizontal position
                switch(this.options.positionNavigation){
                    case 'out-left-top':
                    case 'out-left-bottom':
                    case 'in-left-top':
                    case 'in-left-bottom':
                    case 'in-left-middle':
                        nav_css_additional['left'] = '20px';
                        break;
                    case 'out-center-top':
                    case 'out-center-bottom':
                    case 'in-center-top':
                    case 'in-center-bottom':
                        nav_css_additional['left'] = '50%';
                        if(inner_width) nav_css_additional['margin-left'] = (-1*inner_width/2)+'px';
                        break;
                    case 'out-right-top':
                    case 'out-right-bottom':
                    case 'in-right-top':
                    case 'in-right-bottom':
                    case 'in-right-middle':
                        nav_css_additional['right'] = '20px';
                        break;
                }
                var nav_css = {
                    'position': 'absolute',
                    'z-index': '3'
                };
                $.extend(nav_css, nav_css_additional);
                $navigation.css(nav_css);
                $nav_link.css({
                    'background-color': that.options.navigationColor
                });
                $navigation.find('.nav-link:first').css({
                    'background-color': that.options.navigationHighlightColor
                });
                $nav_link.hover(function(){
                    $(this).css({
                        'background-color': that.options.navigationHoverColor
                    });
                },function(){
                    $(this).css({
                        'background-color': $(this).data('num') == that.current_slide ? that.options.navigationHighlightColor : that.options.navigationColor
                    });
                });
            }
            $nav_link.unbind("click");
            $nav_link.on('click', function(e){
                e && e.preventDefault();
                var navigation = this;
                var navigation_num = $(navigation).data('num');
                if(navigation_num == that.current_slide) return;
                if(that.play_timer == false || that.on_transition == true) return;
                that._stopTimer(function(){
                    if(navigation_num > 0) that.current_slide = navigation_num - 1;
                    else that.current_slide = that.num_slides - 1;
                    that._startTimer(function(){
                        that._next();
                    });
                });
            });
        },
        _attachControl: function(){
            var that = this;
            this.$ele_in.append('<div class="button-previous button-slider">&lsaquo;</div>');
            this.$ele_in.append('<div class="button-next button-slider">&rsaquo;</div>');
            this.$ele_in.children('.button-slider').css({
                'display': 'none',
                'z-index': '10',
                'user-select': 'none'
            });
            if(!this.options.userCSS){
                this.$ele_in.children('.button-slider').addClass("abs text_36em line_h_1em text_al_c dis_opa_05 wh_12em bor_rad_50 pointer").css({
                    'color': this.options.controlColor,
                    'background-color': this.options.controlBackgroundColor
                });
                //positionControl: 'left-right', // 'left-right', 'top-center', 'bottom-center', 'top-left', 'top-right', 'bottom-left', 'bottom-right'
                var css_previous, css_next;
                switch(this.options.positionControl){
                    case 'left-right':
                        css_previous = {
                            'left': '10%',
                            'top': '50%',
                            'margin-top': '-20px'
                        };
                        css_next = {
                            'right': '10%',
                            'top': '50%',
                            'margin-top': '-20px'
                        };
                        break;
                    case 'top-center':
                        css_previous = {
                            'left': '50%',
                            'top': '10%',
                            'margin-left': '-50px'
                        };
                        css_next = {
                            'left': '50%',
                            'top': '10%',
                            'margin-left': '10%'
                        };
                        break;
                    case 'bottom-center':
                        css_previous = {
                            'left': '50%',
                            'bottom': '10%',
                            'margin-left': '-50px'
                        };
                        css_next = {
                            'left': '50%',
                            'bottom': '10%',
                            'margin-left': '10%'
                        };
                        break;
                    case 'top-left':
                        css_previous = {
                            'left': '10%',
                            'top': '10%'
                        };
                        css_next = {
                            'left': '70px',
                            'top': '10%'
                        };
                        break;
                    case 'top-right':
                        css_previous = {
                            'right': '70px',
                            'top': '10%'
                        };
                        css_next = {
                            'right': '10%',
                            'top': '10%'
                        };
                        break;
                    case 'bottom-left':
                        css_previous = {
                            'left': '10%',
                            'bottom': '10%'
                        };
                        css_next = {
                            'left': '70px',
                            'bottom': '10%'
                        };
                        break;
                    case 'bottom-right':
                        css_previous = {
                            'right': '70px',
                            'bottom': '10%'
                        };
                        css_next = {
                            'right': '10%',
                            'bottom': '10%'
                        };
                        break;
                }
                this.$ele_in.children('.button-previous').css(css_previous);
                this.$ele_in.children('.button-next').css(css_next);
            }
            this.$ele_in.children('.button-previous').unbind("click");
            this.$ele_in.children('.button-previous').on('click', function(e){
                e && e.preventDefault();
                if(that.play_timer == false || that.on_transition == true) return;
                that._stopTimer(function(){
                    that._startTimer(function(){
                        that._prev(function(){
                            that.is_pause = true; //Because the mouse pointer is on the button
                        });
                    });
                });
            });
            this.$ele_in.children('.button-next').unbind("click");
            this.$ele_in.children('.button-next').on('click', function(e){
                e && e.preventDefault();
                if(that.play_timer == false || that.on_transition == true) return;
                that._stopTimer(function(){
                    that._startTimer(function(){
                        that._next(function(){
                            that.is_pause = true; //Because the mouse pointer is on the button
                        });
                    });
                });
            });
        },
        _showProgress: function(percent){
            var that = this;
            if(!this.options.showProgress) return;
            if(this.$ele_in.children('.slider-progress').length  == 0){
                this.$ele_in.append('<div class="slider-progress"><div class="bar"></div></div>');
                this._$progress_bar = this.$ele_in.find('.slider-progress:first .bar');
                this.$ele_in.children('.slider-progress').css({
                    'z-index': '4'
                });
                this._$progress_bar.css({
                    'height': '100%'
                });
                if(!this.options.userCSS){
                    this.$ele_in.children('.slider-progress').css({
                        'position': 'absolute',
                        'bottom': '0',
                        'left': '0',
                        'height': '0.5%',
                        'width': '100%',
                        'background-color': 'transparent',
                        'opacity': '0.7'
                    });
                    this._$progress_bar.css({
                        'width': '0%',
                        'background-color': this.options.progressColor
                    });
                }
            }
            if(typeof percent != 'undefined'){
                this._$progress_bar.css('width', percent+'%');
            }
        },
        _showButtons: function(){
            this.$ele_in.children('.button-slider').fadeIn();
        },
        _hideButtons: function(){
            this.$ele_in.children('.button-slider').fadeOut();
        },
        _playSlide: function(){
            var that = this;
            if(this.num_slides > 1){
                this._startTimer(function(){ that._next(); });
            }
            else {
                this._next();
            }
        },
        _stopTimer: function(callback){
            var that = this;
            this.play_timer = false;
            var timer = setInterval(function(){
                if(that.active_timer == false) {
                    clearInterval(timer);
                    if(typeof callback == 'function') callback();
                }
            }, 100);
        },
        _startTimer: function(callback){
            var that = this;
            this.play_timer = true;
            this.active_timer = true;
            var start_time = (new Date()).getTime();
            var end_time = start_time + that.options.duration;
            var elapsed_time = 0;
            this._showProgress(0);
            callback();
            var frame = function(){
                if(that.play_timer == false) {
                    that._showProgress(0);
                    that.active_timer = false;
                    return false;
                }
                var current_time = (new Date()).getTime();
                if(that.is_pause == true || that.on_transition){
                    if(elapsed_time == 0) elapsed_time = current_time - start_time;
                    that.requestFrame.call(window, frame);
                }
                else {
                    if(elapsed_time > 0){
                        start_time = current_time - elapsed_time;
                        end_time = start_time + that.options.duration;
                        elapsed_time = 0;
                    }
                    if(current_time > end_time) {
                        that._showProgress(100);
                        start_time = (new Date()).getTime();
                        end_time = start_time + that.options.duration;
                        that._next(function(){
                            that._showProgress(0);
                        });
                    }
                    else {
                        var percent = ((current_time - start_time)/that.options.duration)*100;
                        that._showProgress(percent);
                    }
                    that.requestFrame.call(window, frame);
                }
            };
            frame();
        },
        _isLoadedImages: function(arr_images, callback, index, arr_size){
            if(typeof arr_images == 'undefined' || arr_images.length < 1) {
                if(typeof callback == 'function') callback();
                return;
            }
            if(typeof index == 'undefined') {
                index = 0;
            }
            if(typeof arr_size == 'undefined') {
                arr_size = [];
            }
            var that = this;
            var src = arr_images[index];
            var img = new Image();
            img.onload = img.onerror = function(){
                arr_size.push({width: img.width, height: img.height});
                if(index == arr_images.length - 1 && typeof callback == 'function') callback(arr_size);
                else that._isLoadedImages(arr_images, callback, ++index, arr_size);
            };
            img.src = src;
        },
        _preloadImages: function(arr_images, callback){
            this._isLoadedImages(arr_images, callback);
        },
        _next: function(callback){
            var that = this;
            this.on_transition = true;
            this.is_pause = true;
            var $element;
            if(typeof this.current_slide == 'undefined') {
                this.current_slide = 0;
                $element = this.$sliders.eq(0);
            }
            else {
                if(this.current_slide < this.num_slides - 1) this.current_slide++;
                else this.current_slide = 0;
                $element = this.$sliders.eq(this.current_slide);
            }
            that._prev_next_process($element, callback,'next');
        },
        _prev: function(callback){
            var that = this;
            this.on_transition = true;
            this.is_pause = true;
            var $element;
            if(this.current_slide > 0) this.current_slide--;
            else this.current_slide = this.num_slides - 1;
            $element = this.$sliders.eq(this.current_slide);
            that._prev_next_process($element, callback,'prev');
        },
        _prev_next_process: function($element, callback,action){
            this.$very_current_slide = $element;
            var that = this;
            var first_image_src = $element.data('images')[0];
            this._isLoadedImages($element.data('images'), function(arr_size){
                that.is_pause = false;
                that.$ele.css('visibility', 'visible');
                if($element.data('has-main-image')){
                    $element.data('original', {'width': arr_size[0].width, 'height': arr_size[0].height});
                }
                else{
                    var original_width, original_height;
                    if(that.options.width && that.options.height){
                        original_width = that.options.width;
                        original_height = that.options.height;
                    }
                    else {
                        var $active = that.$ele_projector.children('.ak-is_active');
                        original_width = $active.outerWidth(true);
                        original_height = $active.outerHeight(true);
                    }
                    $element.data('original', {'width': original_width, 'height': original_height});
                }
                if(typeof callback == 'function') callback();
                //we resize slide size because slide size could be bigger than window size.
                that._resize($element, function(){
                    that._updateNavigation();
                    if($element.find('[data-pos]').length > 0){
                        that._showAnimation($element,action, function(){

                        });
                    }
                    else {
                        that._showImage($element, function(){
                        },action);
                    }
                });
            });
        },
        _showImage: function($element, callback,action){
            var that = this;
            var transition = $element.data('transition') ? $element.data('transition') : this.options.transition;
            this._transition($element, transition, function(){
                that.on_transition = false;
                if(typeof callback == 'function') callback();
            });
        },
        /*
         * callback : after transition
         * callback_ani: after both transition and inner animation
         */
        _showAnimation: function($element, action,callback, callback_ani){
            var that = this;
            var transition = action=='next' ? ($element.data('transition') ? $element.data('transition') : this.options.transition):($element.data('transitionExt') ? $element.data('transitionExt') : this.options.transitionExt);
            //var transition = $element.data('transitionExt') ? $element.data('transitionExt') : this.options.transitionExt;
            this._transition($element, transition, function(){
                that.on_transition = false;
                if(typeof callback == 'function') callback();
                var arr_img_element = [];
                $element.children('[data-pos]').each(function(){
                    var pos = $(this).data('pos');
                    if(typeof pos == 'string')
                        pos = $(this).data('pos').replace(/[\s\[\]\']/g, '').split(',');
                    if(pos.length >= 2){
                        $(this).css({
                            'display': 'none',
                            'position': 'absolute',
                            'top': pos[0],
                            'left': pos[1]
                        });
                    }
                    arr_img_element.push(this);
                });
                that._playAnimation(arr_img_element, function(){
                    if(typeof callback_ani == 'function') callback_ani();
                });
            });
        },
        _transition_prepare: function($element){
            var that = this;
            if($element.data('lazy-src')){
                $element.attr('src', $element.data('lazy-src'));
            }
            if($element.data('lazy-background') && $element.children('.lazy-background').length == 0){
                var html = '<img src="'+$element.data('lazy-background')+'" class="lazy-background" />';
                $(html).prependTo($element).css({
                    'position': 'absolute',
                    'top': '0',
                    'left': '0',
                    'z-index': '-1'
                });
                if ($element.children("cite").length < 1) {
                    $element.append("<cite class=\"dis_none_im\" data-pos=\"['0', '0', '0', '0']\"></cite>");
                }
                if ($element.children("img")[0].naturalWidth > $(window).width()) {
                    $element.children("img").css({
                        'margin-left': ($(window).width() - $element.children("img")[0].naturalWidth) /3
                    });
                    $(window).resize(function(){
                        $element.children("img").css({
                            'margin-left': ($(window).width() - $element.children("img")[0].naturalWidth) /3
                        });
                    });
                }
            }
            $element.find('[data-lazy-src]').each(function(){
                $(this).attr('src', $(this).data('lazy-src'));
            });
            $element.find('[data-lazy-background]').each(function(){
                $(this).css('background-image', 'url('+$(this).data('lazy-background')+')');
            });
        },
        _transition: function($element, transition, callback){
            var that = this;
            var $active = this.$ele_projector.children('.ak-is_active:first');
            var reset = function(){
                $active.css({
                    'display': 'none',
                    'top': '0%',
                    'left': '0%'
                });
                $active.css('z-index', '');
                $active.children('[data-pos]').css('display', 'none');
                $active.removeClass('ak-is_active');
                $element.css({
                    'display': 'block',
                    'top': '0%',
                    'left': '0%',
                    'z-index': ''
                });
                $element.addClass('ak-is_active');
            };
            if(transition == 'random')
                transition = this.all_transitions[Math.floor(Math.random()*this.all_transitions.length)];
            transition = transition.replace(/-/g, '_');
            var transition_func = eval('this._transition_'+transition);
            if(typeof transition_func == 'function') {
                this._transition_prepare($element);
                transition_func.call(this, $element, this.options.transitionSpeed, function(){
                    reset();
                    callback();
                });
            }
            else {
                this._transition_prepare($element);
                this._transition_slide($element, this.options.transitionSpeed, function(){
                    reset();
                    callback();
                });
            }
        },
        _transition_slide_left: function($element, duration, callback){
            this._transition_slide($element, duration, callback, 'left');
        },
        _transition_slide_right: function($element, duration, callback){
            this._transition_slide($element, duration, callback, 'right');
        },
        _transition_slide_top: function($element, duration, callback){
            this._transition_slide($element, duration, callback, 'top');
        },
        _transition_slide_bottom: function($element, duration, callback){
            this._transition_slide($element, duration, callback, 'bottom');
        },
        _transition_slide: function($element, duration, callback, direction){
            var that = this;
            if(this.$ele_projector.children('.ak-is_active').length == 0){
                $element.css({
                    'display': 'block',
                    'top': '0%',
                    'left': '0%'
                });
                $element.addClass('ak-is_active');
                if(typeof callback != 'undefined') callback();
                return;
            }
            else {
                if(typeof direction == 'undefined') direction = 'left';
                var pos_from_top, pos_from_left, pos_to_top, pos_to_left;
                switch(direction){
                    case 'left':
                        pos_from_top = '0%';
                        pos_from_left = '100%';
                        pos_to_top = '0%';
                        pos_to_left = '-100%';
                        break;
                    case 'right':
                        pos_from_top = '0%';
                        pos_from_left = '-100%';
                        pos_to_top = '0%';
                        pos_to_left = '100%';
                        break;
                    case 'top':
                        pos_from_top = '100%';
                        pos_from_left = '0%';
                        pos_to_top = '-100%';
                        pos_to_left = '0%';
                        break;
                    case 'bottom':
                        pos_from_top = '-100%';
                        pos_from_left = '0%';
                        pos_to_top = '100%';
                        pos_to_left = '0%';
                        break;
                }
                this.$ele_projector.append('<div class="slide-old" style="display: none;"></div>');
                this.$ele_projector.append('<div class="slide-new" style="display: none;"></div>');
                this.$ele_projector.children('.ak-is_active:first').clone().appendTo(this.$ele_projector.children('.slide-old')).removeClass("ak-is_active");
                $element.clone().appendTo(this.$ele_projector.children('.slide-new')).removeClass("ak-is_active");
                var $slide_old = this.$ele_projector.children('.slide-old');
                var $slide_new = this.$ele_projector.children('.slide-new');
                //To prevent blink
                setTimeout(function(){
                    $slide_old.css({
                        'display': 'block',
                        'position': 'absolute',
                        'overflow': 'hidden',
                        'top': '0',
                        'left': '0',
                        'width': '100%',
                        'height': '100%',
                        'z-index': '2'
                    });
                    $slide_new.css({
                        'display': 'block',
                        'position': 'absolute',
                        'overflow': 'hidden',
                        'top': pos_from_top,
                        'left': pos_from_left,
                        'width': '100%',
                        'height': '100%',
                        'z-index': '2'
                    });
                    $slide_old.children().show();
                    $slide_new.children().show();
                    that._animate(
                        $slide_old,
                        null,
                        {
                            'top': pos_to_top,
                            'left': pos_to_left
                        },
                        duration,
                        null,
                        function(){
                            $slide_old.remove();
                        }
                    );
                    that._animate(
                        $slide_new,
                        null,
                        {
                            'top': '0%',
                            'left': '0%'
                        },
                        duration,
                        null,
                        function(){
                            $slide_new.remove();
                            if(typeof callback == 'function') callback();
                        }
                    );
                }, 30);
            }
        },
        _transition_fade: function($element, duration, callback){
            var that = this;
            if(this.$ele_projector.children('.ak-is_active').length == 0){
                $element.css({
                    'display':'block',
                    'left': '0%'
                });
                $element.addClass('ak-is_active');
                if(typeof callback != 'undefined') callback();
                return;
            }
            else {
                this.$ele_projector.append('<div class="fade-old" style="display:none;"></div>');
                this.$ele_projector.append('<div class="fade-new" style="display:none;"></div>');
                this.$ele_projector.children('.ak-is_active:first').clone().appendTo(this.$ele_projector.children('.fade-old')).removeClass("ak-is_active");
                $element.clone().appendTo(this.$ele_projector.children('.fade-new')).removeClass("ak-is_active");
                var $fade_old = this.$ele_projector.children('.fade-old');
                var $fade_new = this.$ele_projector.children('.fade-new');
                //To prevent blink
                setTimeout(function(){
                    $fade_old.children().show();
                    $fade_new.children().show();
                    that._animate(
                        $fade_old,
                        {
                            'display': 'block',
                            'position': 'absolute',
                            'overflow': 'hidden',
                            'width': '100%',
                            'height': '100%',
                            'z-index': '2'
                        },
                        {
                            'opacity': '0'
                        },
                        duration,
                        null,
                        function(){
                            $fade_old.remove();
                        }
                    );
                    that._animate(
                        $fade_new,
                        {
                            'display': 'block',
                            'position': 'absolute',
                            'overflow': 'hidden',
                            'width': '100%',
                            'height': '100%',
                            'z-index': '2',
                            'opacity': '0'
                        },
                        {
                            'opacity': '1'
                        },
                        duration,
                        null,
                        function(){
                            $fade_new.remove();
                            if(typeof callback == 'function') callback();
                        }
                    );
                }, 30);
            }
        },
        _transition_split3d: function($element, duration, callback){
            this._transition_split($element, duration, callback, true);
        },
        _transition_split: function($element, duration, callback, enable3d){
            var that = this;
            if(this.$ele_projector.children('.ak-is_active').length == 0){
                $element.css({
                    'display': 'block',
                    'left': '0%'
                });
                $element.addClass('ak-is_active');
                if(typeof callback != 'undefined') callback();
                return;
            }
            else {
                this.$ele_projector.append('<div class="split_up" style="display: none;"></div>');
                this.$ele_projector.append('<div class="split_down" style="display: none;"></div>');
                this.$ele_projector.children('.ak-is_active:first').clone().appendTo(this.$ele_projector.children('.split_up')).removeClass("ak-is_active");
                this.$ele_projector.children('.ak-is_active:first').clone().appendTo(this.$ele_projector.children('.split_down')).removeClass("ak-is_active");
                var $split_up = this.$ele_projector.children('.split_up');
                var $split_down = this.$ele_projector.children('.split_down');
                //To prevent blink
                setTimeout(function(){
                    $split_up.children().css({
                        'top': '0',
                        'left': '0',
                        'height': that.$ele_projector.height()+'px'
                    });
                    $split_down.children().css({
                        'top': 'auto',
                        'bottom': '0',
                        'left': '0',
                        'height': that.$ele_projector.height()+'px',
                        'background-position': 'bottom left'
                    });
                    $element.css({
                        'left': '0%',
                        'display': 'block'
                    });
                    that.$ele_projector.children('.ak-is_active:first').css('display', 'none');
                    $css_split_up = {
                        'top': '-50%',
                        'opacity': '0'
                    };
                    $css_split_down = {
                        'bottom': '-50%',
                        'opacity': '0'
                    };
                    if(typeof enable3d != 'undefined' && enable3d == true){
                        var deg = 10;
                        if(that.current_slide%2 == 0) deg = -1*deg;
                        that.$ele_projector.css({
                            'perspective': '400px'
                        });
                        $.extend($css_split_up, {'transform': 'rotateZ('+deg+'deg) translateZ(238px)'});
                        $.extend($css_split_down, {'transform': 'rotateZ('+(-1*deg)+'deg) translateZ(238px)'});
                    }
                    that._animate(
                        $split_up,
                        {
                            'display': 'block',
                            'position': 'absolute',
                            'overflow': 'hidden',
                            'z-index': '2',
                            'top': '0',
                            'left': '0',
                            'width': '100%',
                            'height': that.$ele_projector.height()/2+'px',
                            'opacity': '1'
                        },
                        $css_split_up,
                        duration,
                        null,
                        null
                    );
                    that._animate(
                        $split_down,
                        {
                            'display': 'block',
                            'position': 'absolute',
                            'overflow': 'hidden',
                            'z-index': '2',
                            'bottom': '0',
                            'left': '0',
                            'width': '100%',
                            'height': that.$ele_projector.height()/2+'px',
                            'opacity': '1'
                        },
                        $css_split_down,
                        duration,
                        null,
                        function(){
                            $split_up.remove();
                            $split_down.remove();
                            if(typeof callback == 'function') callback();
                        }
                    );
                }, 30);
            }
        },
        _transition_door: function($element, duration, callback){
            var that = this;
            if(this.$ele_projector.children('.ak-is_active').length == 0){
                $element.css({
                    'display': 'block',
                    'left': '0%'
                });
                $element.addClass('ak-is_active');
                if(typeof callback != 'undefined') callback();
                return;
            }
            else {
                //this.$ele_projector.children('.ak-is_active:first').css('z-index', '1');
                this.$ele_projector.append('<div class="split_left" style="display: none;"></div>');
                this.$ele_projector.append('<div class="split_right" style="display: none;"></div>');
                this.$ele_projector.children('.ak-is_active:first').clone().appendTo(this.$ele_projector.children('.split_left')).removeClass("ak-is_active");
                this.$ele_projector.children('.ak-is_active:first').clone().appendTo(this.$ele_projector.children('.split_right')).removeClass("ak-is_active");
                var $split_left = this.$ele_projector.children('.split_left');
                var $split_right = this.$ele_projector.children('.split_right');
                //To prevent blink
                setTimeout(function(){
                    $split_left.children().css({
                        'top': '0',
                        'left': '0',
                        'width': that.$ele_projector.width()+'px'
                    });
                    $split_right.children().css({
                        'top': '0',
                        'left': 'auto',
                        'right': '0',
                        'width': that.$ele_projector.width()+'px',
                        'background-position': 'top right'
                    });
                    $element.css({
                        'left': '0%',
                        'display': 'block'
                    });
                    that.$ele_projector.children('.ak-is_active:first').css('display', 'none');
                    that._animate(
                        $split_left,
                        {
                            'display': 'block',
                            'position': 'absolute',
                            'overflow': 'hidden',
                            'z-index': '2',
                            'top': '0',
                            'left': '0',
                            'width': that.$ele_projector.width()/2+'px',
                            'height': '100%'
                        },
                        {
                            'left': '-50%'
                        },
                        duration,
                        null,
                        function(){
                            $split_left.remove();
                        }
                    );
                    that._animate(
                        $split_right,
                        {
                            'display': 'block',
                            'position': 'absolute',
                            'overflow': 'hidden',
                            'z-index': '2',
                            'top': '0',
                            'right': '0',
                            'width': that.$ele_projector.width()/2+'px',
                            'height': '100%'
                        },
                        {
                            'right': '-50%'
                        },
                        duration,
                        null,
                        function(){
                            $split_right.remove();
                            if(typeof callback == 'function') callback();
                        }
                    );
                }, 30);
            }
        },
        _transition_wave_left: function($element, duration, callback){
            this._transition_wave($element, duration, callback, 'left');
        },
        _transition_wave_right: function($element, duration, callback){
            this._transition_wave($element, duration, callback, 'right');
        },
        _transition_wave_top: function($element, duration, callback){
            this._transition_wave($element, duration, callback, 'top');
        },
        _transition_wave_bottom: function($element, duration, callback){
            this._transition_wave($element, duration, callback, 'bottom');
        },
        _transition_wave: function($element, duration, callback, direction){
            var that = this;
            if(this.$ele_projector.children('.ak-is_active').length == 0){
                $element.css({
                    'display': 'block',
                    'left': '0%'
                });
                $element.addClass('ak-is_active');
                if(typeof callback != 'undefined') callback();
                return;
            }
            else {
                this.$ele_projector.append('<div class="split_wave" style="display: none;"></div>');
                $element.clone().appendTo(this.$ele_projector.children('.split_wave')).removeClass("ak-is_active");
                var $split_wave = this.$ele_projector.children('.split_wave');
                if(typeof direction == 'undefined') direction = 'left';
                var to_css;
                switch(direction){
                    case 'left':
                        $split_wave.children().css({
                            'left': '0',
                            'right': '',
                            'top': '',
                            'bottom': ''
                        });
                        $split_wave.css({
                            'top': '0',
                            'left': '0',
                            'width': '0%',
                            'height': '100%'
                        });
                        to_css = {
                            'width': '100%',
                            'opacity': '1'
                        };
                        break;
                    case 'right':
                        $split_wave.children().css({
                            'left': '',
                            'right': '0',
                            'top': '',
                            'bottom': ''
                        });
                        $split_wave.css({
                            'top': '0',
                            'right': '0',
                            'width': '0%',
                            'height': '100%'
                        });
                        to_css = {
                            'width': '100%',
                            'opacity': '1'
                        };
                        break;
                    case 'top':
                        $split_wave.children().css({
                            'left': '',
                            'right': '',
                            'top': '0',
                            'bottom': ''
                        });
                        $split_wave.css({
                            'top': '0',
                            'left': '0',
                            'width': '100%',
                            'height': '0%'
                        });
                        to_css = {
                            'height': '100%',
                            'opacity': '1'
                        };
                        break;
                    case 'bottom':
                        $split_wave.children().css({
                            'left': '',
                            'right': '',
                            'top': '',
                            'bottom': '0'
                        });
                        $split_wave.css({
                            'bottom': '0',
                            'left': '0',
                            'width': '100%',
                            'height': '0%'
                        });
                        to_css = {
                            'height': '100%',
                            'opacity': '1'
                        };
                        break;
                }
                $split_wave.children().show();
                //To prevent blink
                setTimeout(function(){
                    var jQueryAnimation = false;
                    //right and bottom animation shakes with css3 transition
                    if(direction == 'right' || direction == 'bottom') jQueryAnimation = true;
                    that._animate(
                        $split_wave,
                        {
                            'display': 'block',
                            'position': 'absolute',
                            'overflow': 'hidden',
                            'z-index': '2',
                            'opacity': '0.3'
                        },
                        to_css,
                        duration,
                        null,
                        function(){
                            $split_wave.remove();
                            if(typeof callback == 'function') callback();
                        },
                        jQueryAnimation
                    );
                }, 30);
            }
        },
        _playAnimation: function(arr_img_element, callback){
            var that = this;
            var $img_element = $(arr_img_element.shift());
            switch($img_element.data('effect')){
                case 'fadein':
                    this._animate(
                        $img_element,
                        {
                            'display': 'block',
                            'opacity': '0'
                        },
                        {
                            'opacity': '1'
                        },
                        $img_element.data('duration') ? $img_element.data('duration') : 400,
                        $img_element.data('delay') ? $img_element.data('delay') : null,
                        function(){
                            if(arr_img_element.length > 0) that._playAnimation(arr_img_element, callback);
                            else callback();
                        }
                    );
                    break;
                case 'move':
                    $img_element.css({
                        'display': 'block'
                    });
                    var pos = $img_element.data('pos');
                    if(typeof pos == 'string')
                        pos = $img_element.data('pos').replace(/[\s\[\]\']/g, '').split(',');
                    if(pos.length == 4){
                        this._animate(
                            $img_element,
                            {
                                'opacity': '0'
                            },
                            {
                                'top': pos[2],
                                'left': pos[3],
                                'opacity': 1
                            },
                            $img_element.data('duration') ? $img_element.data('duration') : 400,
                            $img_element.data('delay') ? $img_element.data('delay') : null,
                            function(){
                                if(arr_img_element.length > 0) that._playAnimation(arr_img_element, callback);
                                else callback();
                            }
                        );
                    }
                    break;
            }
        }
    };
    $.fn.Andrew_Slider = function (options) {
        if (typeof options === 'string') {
            var data = $this.data('Andrew_Slider');
            if (!data) $this.data('Andrew_Slider', (data = new Andrew_Slider(this, options)));
            return data[options].apply(data, Array.prototype.slice.call(arguments, 1));
        }
        return this.each(function () {
            var $this = $(this);
            $this.find("span").css({"position":"absolute","top":"-100%",});
            var data = $this.data('Andrew_Slider');
            if (!data) $this.data('Andrew_Slider', (data = new Andrew_Slider(this, options)));
            else data.constructor(this, options);
            data._init();
        });
    };
    $.fn.Andrew_Slider.Constructor = Andrew_Slider;
}(jQuery));

/*-----------------------------------------------Andrew_Mkinfinite-------------------------------------------*/
(function($){
    jQuery.fn.Andrew_Mkinfinite = function(options){
        var options = $.extend({
            maxZoom:           1.25,
            imagesRatio:       1.5,
            height:             "100%",
            animationTime:     10000,
            animationInterval: 10,
            isFixedBG:         false,
            zoomIn:            true,
            imagesList: new Array(),
        }, options);
        var currentImage  = 1;
        var currentZoom   = 1;
        var animationStep = 0.1;
        var $object;
        var make = function(){
            currentZoom = options.zoomIn ? options.maxZoom : 1;
            animationStep = (options.maxZoom - 1) / ( options.animationTime / options.animationInterval );
            if (!options.zoomIn){
                animationStep = -1 * animationStep;
            }
            $object = $(this);
            $object.css({
                'height': options.height,
                'background-position': '50% 50%',
                'background-repeat': 'no-repeat'
            });
            if (options.imagesList.length > 1){
                calculateZoom(currentImage);
            }
            animateBG();
        };
        var calculateZoom = function(setImageNumber){
            var nBGw = ( options.isFixedBG ? $(window).width() : $object.width() ) * currentZoom;
            var nBGh = $object.height() * currentZoom;
            if ( (nBGw / nBGh) > options.imagesRatio ){
                nBGw = Math.round(nBGw);
                nBGh = Math.round(nBGw / options.imagesRatio);
            } else {
                nBGw = Math.round(nBGh * options.imagesRatio);
                nBGh = Math.round(nBGh);
            }
            if (setImageNumber && (setImageNumber > 0)){
                $object.css({
                    'background-size': nBGw + 'px ' + nBGh + 'px',
                    'background-image': 'url(' + options.imagesList[setImageNumber - 1] + ')'
                });
                var imgLoader = new Image();
                imgLoader.src = options.imagesList[setImageNumber % options.imagesList.length];
            } else {
                $object.css('background-size', nBGw + 'px ' + nBGh + 'px');
            }
        }
        var animateBG = function(){
            if ( options.zoomIn && (currentZoom >= 1) || !options.zoomIn && (currentZoom <= options.maxZoom) ){
                setTimeout(function(){
                    calculateZoom();
                    currentZoom = currentZoom - animationStep;
                    animateBG();
                }, options.animationInterval);
            } else {
                currentZoom = options.zoomIn ? options.maxZoom : 1;
                if (options.imagesList.length > 1){
                    currentImage = currentImage % options.imagesList.length + 1;
                    calculateZoom(currentImage);
                } else {
                    calculateZoom();
                }
                animateBG();
            }
        }
        return this.each(make);
    };
}(jQuery));

/*-----------------------------------------------Andrew_Textarea-------------------------------------------*/
(function($){
    $.fn.Andrew_Textarea = function(setting) {
        var opm = $.extend({
                maxlength: 300,
                rows: 6,
                onTextVal: function() {}
            },
            setting);
        var txt =$(this);
        if (txt.length > 0) {
            txt.each(function(){ //input元素加maxlength属性后控制自定义字数
                $(this).after('<span class="dis_block ovh abs left_0 center text_al_r text_08em"><var class="text_08em mr_02em" style="color: #f16a6a;">0</var>/<var class="text_08em mr_05em">'+opm.maxlength+'</var></span>');
                $(this).next("span").css({
                    "width": $(this).outerWidth()
                });
                $(this).attr("rows",opm.rows).attr("maxlength",opm.maxlength);
                $(this).parent().css({
                    "padding-bottom": $(this).next("span").height() * 1.2+"px"
                })
            });
            var len = 0;
            txt.on("input propertychange",function(e){
                if( len >= opm.maxlength && e.keyCode == 8 ){
                    return;
                }else{
                    // 取出回车字符
                    var textareaVal = ($(this).val().replace(/<(.+?)>/gi,"&lt;$1&gt;")).replace(/\n/gi,"|");
                    // 回车数量
                    var entLen = textareaVal.split('|').length-1;
                    // 不包含回车的数量
                    var strLen = textareaVal.split('|').join('').length;
                    $(this).attr('maxlength',opm.maxlength+(entLen*2));
                    len = strLen;
                    if( len >= opm.maxlength ){
                        len = opm.maxlength;
                    }
                    $(this).next("span").children("var").eq(0).html(len);
                    var data = $(this).val();
                    opm.onTextVal(data);
                }
            });
        }
    };
}(jQuery));

/*-----------------------------------------------Andrew_scrollTopFix-------------------------------------------*/
(function($){
    $.fn.Andrew_scrollTopFix = function(setting) {
        var option = $.extend({
                scrollTop:"",
                scrollLeft:"",
                scrollClass: "",
            },
            setting);
        var ast =$(this);
        $(window).scroll(function () {
            if ($("header").length >0) {
                var winscrolltop = $(window).scrollTop() + $("header").outerHeight();
            } else {
                var winscrolltop = $(window).scrollTop();
            }
            if (winscrolltop >= option.scrollTop) {
                ast.addClass(option.scrollClass);
                ast.css({
                    "left": option.scrollLeft + "px"
                });
            } else {
                ast.removeClass(option.scrollClass);
                ast.removeAttr("style");
            }
        });
    };
}(jQuery));

/*-----------------------------------------------Andrew_Tabs-------------------------------------------*/
(function($){
    var Plugin = function(elem, options) {
        this.$wrapper = elem;

        this.$tab_list = this.$wrapper.children('nav').children('ul').children('li');
        this.$tabCont_art = this.$wrapper.children("article");
        this.$tabCont_wrap = this.$wrapper.children("article").children('div');
        this.$tab_cont = this.$tabCont_wrap.find('section');
        this.timer = null;
        this.playTimer = null;
        this.iNow = 0;

        this.defaults = {
            curDisplay: 1,
            mouse: 'click',
            playDelay: 1000,
            boxheight: false,
            navlength: false,
            fullclass: 'bor_bottom2 bor_title c_title',
            emptyclass: 'bor_bottom bor_gray_ddd',
            changeMethod: 'default',
            autoPlay: false,
            AjaxList: new Array(),
            callback: function () { } //回调函数
        };

        this.opts = $.extend({},
            this.defaults, options);
    };
    Plugin.prototype = {
        inital: function() {
            var self = this;

            this.setData();
            this.tabInital();
            if (this.opts.mouse === 'click') {
                this.$tab_list.click(function() {
                    self.changeTab($(this).index());

                    self.iNow = $(this).index();
                });
            } else if (this.opts.mouse === 'hover') {
                this.$tab_list.hover(function() {
                        var cur_obj = this;

                        clearTimeout(self.timer);
                        self.timer = setTimeout(function() {
                                self.changeTab($(cur_obj).index());
                            },
                            30);

                        self.iNow = $(this).index();
                    },
                    function() {
                        clearTimeout(self.timer);
                    });
            } else {
                this.$tab_list.click(function() {
                    self.changeTab($(this).index());

                    self.iNow = $(this).index();
                });
            }

            if (this.opts.autoPlay) {
                clearInterval(this.playTimer);
                this.playTimer = setInterval(function() {
                        self.autoPlay();
                    },
                    this.opts.playDelay);

                this.$wrapper.hover(function() {
                        //clearInterval(self.playTimer); //鼠标滑动后自动播放将会停止
                    },
                    function() {
                        self.playTimer = setInterval(function() {
                                self.autoPlay();
                            },
                            this.opts.playDelay);
                    });
            }
        },
        setData: function() { // 设置样式
            var curNum = this.opts.curDisplay - 1;
            this.opts.callback(this.$tab_cont.eq(curNum));
            if (this.$tab_list.length == this.opts.navlength) {
                this.$tab_list.removeClass("pl_1em pr_1em");
                this.$tab_list.parent("ul").removeClass("nav_line").addClass("nav_line_c");
                this.$tab_list.parent("ul").addClass("length" + this.$tab_list.length);
            } else {

            }
            this.$tab_cont.css({
                "width": this.$tabCont_art.outerWidth()
            });
            /*this.$tabCont_wrap.parent().css({
                height: this.$tab_cont.eq(0).outerHeight()
            });*/
            if (this.opts.boxheight) {
                this.$tabCont_wrap.parent().css({
                    height: this.opts.boxheight
                });
                this.$tabCont_wrap.css({
                    height: this.opts.boxheight
                });
                this.$tab_cont.css({
                    height: this.opts.boxheight
                });
            }

            var tabCont_w = this.$tab_cont.outerWidth();
            var tabCont_h = this.$tab_cont.outerHeight();
            var tabCont_len = this.$tab_cont.length;

            switch (this.opts.changeMethod) {
                case 'default':
                    this.$tab_cont.css({
                        opacity:'0'
                    });
                    break;
                case 'horizontal':
                    this.$tabCont_wrap.css({
                        width:
                        tabCont_w * tabCont_len
                    });
                    this.$tab_cont.addClass("fl");
                    break;
                case 'vertical':
                    this.$tabCont_wrap.css({
                        height:
                        tabCont_h * tabCont_len
                    });
                    break;
                case 'opacity':
                    this.$tab_cont.css({
                        display:'none'
                    });
                    break;
                case 'ajax':
                    this.$tab_cont.empty();
                    break;
                default:
                    this.$tab_cont.css({
                        opacity:'0'
                    });
                    break;
            }
        },

        tabInital: function() { // 初始化当前显示
            var curNum = this.opts.curDisplay - 1;
            this.$tab_list.removeClass(this.opts.fullclass);
            this.$tab_list.eq(curNum).addClass(this.opts.fullclass);
            if (this.opts.changeMethod === 'default') {
                this.$tab_cont.eq(curNum).css({
                    opacity: '1'
                });
            } else if (this.opts.changeMethod === 'opacity') {
                this.$tab_cont.eq(curNum).css({
                    display: 'block'
                });
            } else if (this.opts.changeMethod === 'ajax') {
                htmlobj=$.ajax({
                    type : "POST",
                    url: this.opts.AjaxList[curNum],
                    async:false,
                });
                this.$tab_cont.html(htmlobj.responseText);
            } else if (this.opts.changeMethod === 'horizontal') {
                this.$tabCont_wrap.css({
                    left: -curNum * this.$tab_cont.outerWidth()
                });
            } else if (this.opts.changeMethod === 'vertical') {
                this.$tabCont_wrap.css({
                    top: -curNum * this.$tab_cont.outerHeight()
                });
            } else {
                this.$tab_cont.eq(curNum).css({
                    opacity: '1'
                });
            }

            this.iNow = this.opts.curDisplay - 1;
        },

        changeTab: function(index) { // 选项卡切换
            this.$tab_list.removeClass(this.opts.fullclass).addClass(this.opts.emptyclass).removeAttr("style");
            this.$tab_list.eq(index).removeClass(this.opts.emptyclass).addClass(this.opts.fullclass);
            this.opts.callback(this.$tab_cont.eq(index));
            switch (this.opts.changeMethod) {
                case 'default':
                    this.$tab_cont.css({
                        opacity:'0'
                    });
                    this.$tab_cont.eq(index).css({
                        opacity:'1'
                    });
                    if (this.opts.boxheight) {
                        this.$tabCont_wrap.parent().css({
                            height:
                            this.opts.boxheight
                        });
                        this.$tab_cont.stop().animate({
                            height:
                            this.opts.boxheight
                        });
                    }
                    break;
                case 'horizontal':
                    this.$tabCont_wrap.stop().animate({
                        left:
                        this.$tab_cont.outerWidth() * -index
                    });
                    if (this.opts.boxheight) {
                        this.$tabCont_wrap.parent().css({
                            height: this.opts.boxheight
                        });
                        this.$tab_cont.stop().animate({
                            height: this.opts.boxheight
                        });
                    } else {
                        this.$tabCont_wrap.parent().stop().animate({
                            height: this.$tab_cont.eq(index).outerHeight()
                        });
                    }
                    break;
                case 'vertical':
                    this.$tabCont_wrap.stop().animate({
                        top:
                        this.$tab_cont.outerHeight() * - index
                    });
                    if (this.opts.boxheight) {
                        this.$tabCont_wrap.parent().css({
                            height: this.opts.boxheight
                        });
                        this.$tab_cont.stop().animate({
                            height: this.opts.boxheight
                        });
                    } else {
                        this.$tabCont_wrap.parent().stop().animate({
                            height: this.$tab_cont.eq(index).outerHeight()
                        });
                    }
                    break;
                case 'opacity':
                    this.$tab_cont.stop().fadeOut();
                    this.$tab_cont.eq(index).stop().fadeIn();
                    break;
                case 'ajax':
                    this.$tab_cont.empty();
                    htmlobjs=$.ajax({
                        type : "POST",
                        url: this.opts.AjaxList[index],
                        async:false,
                        cache: false,
                    });
                    this.$tab_cont.html(htmlobjs.responseText);

                    if (this.opts.boxheight) {
                        this.$tabCont_wrap.parent().css({
                            height:
                            this.opts.boxheight
                        });
                        this.$tab_cont.stop().animate({
                            height:
                            this.opts.boxheight
                        });
                    }
                    break;
                default:
                    this.$tab_cont.css({
                        opacity:'1'
                    });
                    this.$tab_cont.eq(index).css({
                        opacity:'1'
                    });
                    if (this.opts.boxheight) {
                        this.$tabCont_wrap.parent().css({
                            height:
                            this.opts.boxheight
                        });
                        this.$tab_cont.stop().animate({
                            height:
                            this.opts.boxheight
                        });
                    }
                    break;
            }
        },

        autoPlay: function() { // 自动播放
            if (this.iNow === this.$tab_list.length - 1) {
                this.iNow = 0;
            } else {
                this.iNow++;
            }

            this.changeTab(this.iNow);
        },

        constructor: Plugin
    };

    $.fn.Andrew_Tabs = function(options) {
        var plugin = new Plugin(this, options);
        return plugin.inital();
    };

}(jQuery));

/*-----------------------------------------------Andrew_Radio&Andrew_Checkbox&Andrew_Switch-------------------------------------------*/
//(function($){
//    /**
//     * 单选按钮 以data-name来标识分组
//     * @param settings 用户设置参数
//     */
//    $.fn.Andrew_Radio = function(settings) {
//        /* 默认参数 */
//        var _defaults = {
//            checkedClass: "bor_title border8",
//            // 选中状态类名
//            onChange: function(element) {} // onchange回调，返回当前选中项DOM元素
//        };
//
//        var options = $.extend(_defaults, settings || {});
//        if (!this.parent("label").hasClass("ak-Radio")) {
//            this.wrap("<label />");
//        }
//        var radios = this.parent("label");
//        radios.addClass("ak-Radio");
//        radios.attr("data-name",this.attr("name"));
//        radios.css("margin-top", (radios.parent().height() - radios.height()) / 2);
//        radios.find('input[type="checkbox"]').css("margin-top", "-" + (radios.parent().height() - radios.height()) / 2 -1 + "px");
//        radios.each(function() {
//            var $radio = $(this);
//            var _name = $(this).data("name"); // 组name值
//            /*---- 初始化 ----*/
//            // 是否选中以input:radio的选中状态为准,多个选中的话以最后一个为准
//            if ($radio.find('input[type="radio"]').is(':checked')) {
//                var $otherRadios = radios.filter("[data-name='" + _name + "']").not($radio);
//                $radio.addClass(options.checkedClass);
//                $otherRadios.removeClass(options.checkedClass);
//                $otherRadios.find('input[type="radio"]').removeAttr("checked");
//            }
//
//            /*---- 添加事件 ----*/
//            $radio.on("change", function() {
//                if (!$(this).hasClass(options.checkedClass)) {
//                    $(this).addClass(options.checkedClass);
//                    $(this).children('input[type="radio"]').attr("checked","checked");
//                    radios.filter("[data-name='" + _name + "']").not($(this)).removeClass(options.checkedClass); // 切换class状态
//                    radios.filter("[data-name='" + _name + "']").not($(this)).children('input[type="radio"]').removeAttr("checked"); // 切换input状态
//                }
//                options.onChange($(this).children()); // 回调
//            });
//        });
//    };
//    /**
//     * 复选框
//     * @param settings 用户设置参数
//     */
//    $.fn.Andrew_Checkbox = function(settings) {
//        /* 默认参数 */
//        var _defaults = {
//            checkedClass: "bg_title bor_title c_white",
//            disabledClass: "bg_gray_ccc bor_gray_ccc c_white",
//            // 选中状态类名
//            onChange: function(element) {} // onchange回调，返回当前选中项DOM元素组
//        };
//
//        var options = $.extend(_defaults, settings || {});
//        if (!this.parent("label").hasClass("ak-Checkbox")) {
//            this.wrap("<label />");
//        }
//        var checkboxes = this.parent("label");
//        checkboxes.addClass("ak-Checkbox");
//        checkboxes.attr("data-name",this.attr("name"));
//        checkboxes.css("margin-top", (checkboxes.parent().height() - checkboxes.height()) / 2);
//        checkboxes.find('input[type="checkbox"]').css("margin-top", "-" + (checkboxes.parent().height() - checkboxes.height()) / 2 -1 + "px");
//        checkboxes.each(function(ev) {
//            if ($(this).find('input[type="checkbox"]').attr("multiple")) {
//                var $checkbox = $(ev.target);
//            } else {
//                var $checkbox = $(this);
//            }
//            /*---- 初始化 ----*/
//            // 是否选中以input:checkbox的选中状态为准
//            if ($checkbox.find('input[type="checkbox"]').attr("checked")) {
//                $checkbox.addClass(options.checkedClass);
//                $checkbox.find('input[type="checkbox"]').attr("checked","checked");
//            } else if ($checkbox.find('input[type="checkbox"]').is(':disabled')) {
//                $checkbox.addClass(options.disabledClass);
//                $checkbox.find('input[type="checkbox"]').attr("checked","checked");
//            } else {
//                $checkbox.removeClass(options.checkedClass).removeClass(options.disabledClass);
//                $checkbox.find('input[type="checkbox"]').removeAttr("checked");
//            }
//
//            /*---- 添加事件 ----*/
//            $checkbox.on("change", function() {
//                if ($checkbox.find('input[type="checkbox"]').attr("checked")) {
//                    $checkbox.find('input[type="checkbox"]').removeAttr("checked");
//                    $checkbox.removeClass(options.checkedClass)
//                } else {
//                    $checkbox.find('input[type="checkbox"]').attr("checked","checked");
//                    $checkbox.addClass(options.checkedClass);
//                }
//                options.onChange($(this).children()[0].checked); // 回调
//            });
//        });
//    };
//    /**
//     * 开关按钮
//     * @param settings 用户设置参数
//     */
//    $.fn.Andrew_Switch = function(settings) {
//        /* 默认参数 */
//        var _defaults = {
//            checkedClass: "bg_title",
//            disabledClass: "dis_opa_05",
//            // 选中状态类名
//            onChange: function(element) {} // onchange回调，返回当前选中项DOM元素组
//        };
//
//        var options = $.extend(_defaults, settings || {});
//
//        var Switchs = this;
//        Switchs.addClass("ak-Switch");
//        if (Switchs.parent().children("label").length < 1) {
//            Switchs.parent().append("<label />");
//        }
//        Switchs.next("label").attr("data-name",this.attr("name"));
//        Switchs.each(function() {
//            var $switch = $(this);
//            $switch.next("label").css("margin-top", ($switch.next("label").parent().height() - Switchs.next("label").height()) / 2);
//            /*---- 初始化 ----*/
//            // 是否选中以input:checkbox的选中状态为准
//            if ($switch.is(':checked') && !$switch.is(':disabled')) {
//                $switch.next("label").addClass(options.checkedClass).removeClass(options.disabledClass);
//            } else if (!$switch.is(':checked') && $switch.is(':disabled'))  {
//                $switch.next("label").removeClass(options.checkedClass).addClass(options.disabledClass);
//            } else if ($switch.is(':disabled') || $switch.is(':checked')) {
//                $switch.next("label").addClass(options.disabledClass).addClass(options.checkedClass);
//            } else if (!$switch.is(':checked') && !$switch.is(':disabled'))  {
//                $switch.next("label").removeClass(options.checkedClass).removeClass(options.disabledClass);
//            }
//
//            /*---- 添加事件 ----*/
//            $switch.on("change", function() {
//                $(this).next("label").toggleClass(options.checkedClass);
//                options.onChange($(this)[0].checked); // 回调
//            });
//        });
//    };
//}(jQuery));
(function($){
    /**
     * 单选按钮 以data-name来标识分组
     * @param settings 用户设置参数
     */
    $.fn.Andrew_Radio = function(settings) {
        /* 默认参数 */
        var _defaults = {
            checkedClass: "bor_title border8",
            // 选中状态类名
            onChange: function(element) {} // onchange回调，返回当前选中项DOM元素
        };

        var options = $.extend(_defaults, settings || {});
        var radios = this;
        radios.addClass("ak-Radio");
        radios.each(function() {
            var $radio = $(this);
            var _name = $(this).data("name"); // 组name值
            /*---- 初始化 ----*/
            // 是否选中以input:radio的选中状态为准,多个选中的话以最后一个为准
            if ($radio.find('input[type="radio"]').is(':checked')) {
                var $otherRadios = radios.filter("[data-name='" + _name + "']").not($radio);
                $radio.addClass(options.checkedClass);
                $otherRadios.removeClass(options.checkedClass);
                $otherRadios.find('input[type="radio"]').removeAttr("checked");
            }

            /*---- 添加事件 ----*/
            $radio.unbind();
            $radio.on("change",
                function() {
                    if (!$(this).hasClass(options.checkedClass)) {
                        $(this).addClass(options.checkedClass);
                        $(this).children('input[type="radio"]').attr("checked","checked");
                        radios.filter("[data-name='" + _name + "']").not($(this)).removeClass(options.checkedClass); // 切换class状态
                        radios.filter("[data-name='" + _name + "']").not($(this)).children('input[type="radio"]').removeAttr("checked"); // 切换input状态
                    }
                    options.onChange($(this).children()); // 回调
                });
        });
    };
    /**
     * 复选框
     * @param settings 用户设置参数
     */
    $.fn.Andrew_Checkbox = function(settings) {
        /* 默认参数 */
        var _defaults = {
            checkedClass: "bg_title bor_title c_white",
            disabledClass: "bg_gray_ccc bor_gray_ccc c_white",
            // 选中状态类名
            onChange: function(element) {} // onchange回调，返回当前选中项DOM元素组
        };

        var options = $.extend(_defaults, settings || {});
        var checkboxes = this;
        checkboxes.addClass("ak-Checkbox");
        checkboxes.css({
            "margin-top": (checkboxes.parent().height() - checkboxes.height()) / 2,
            "width": checkboxes.parent().height(),
            "height": checkboxes.parent().height(),
            "line-height": checkboxes.parent().height()+"px"
        });
        checkboxes.find('input[type="checkbox"]').css("margin-top", "-" + (checkboxes.parent().height() - checkboxes.height()) / 2 -1 + "px");
        checkboxes.each(function() {
            var $checkbox = $(this);

            /*---- 初始化 ----*/
            // 是否选中以input:checkbox的选中状态为准
            if ($checkbox.find('input[type="checkbox"]').attr("checked")) {
                $checkbox.addClass(options.checkedClass);
                $checkbox.find('input[type="checkbox"]').attr("checked","checked");
            } else if ($checkbox.find('input[type="checkbox"]').is(':disabled')) {
                $checkbox.addClass(options.disabledClass);
                $checkbox.find('input[type="checkbox"]').attr("checked","checked");
            } else {
                $checkbox.removeClass(options.checkedClass).removeClass(options.disabledClass);
                $checkbox.find('input[type="checkbox"]').removeAttr("checked");
            }

            /*---- 添加事件 ----*/
            $checkbox.unbind();
            $checkbox.on("change",
                function() {
                    if ($checkbox.find('input[type="checkbox"]').attr("checked")) {
                        $checkbox.find('input[type="checkbox"]').removeAttr("checked");
                        $checkbox.removeClass(options.checkedClass)
                    } else {
                        $checkbox.find('input[type="checkbox"]').attr("checked","checked");
                        $checkbox.addClass(options.checkedClass);
                    }
                    options.onChange($(this).children()[0].checked); // 回调
                });
        });
    };
    /**
     * 开关按钮
     * @param settings 用户设置参数
     */
    $.fn.Andrew_Switch = function(settings) {
        /* 默认参数 */
        var _defaults = {
            checkedClass: "bg_title",
            disabledClass: "dis_opa_05",
            // 选中状态类名
            onChange: function(element) {} // onchange回调，返回当前选中项DOM元素组
        };

        var options = $.extend(_defaults, settings || {});

        var Switchs = this;
        Switchs.addClass("ak-Switch");
        Switchs.each(function() {
            var $switch = $(this);
            $switch.next("label").css("margin-top", ($switch.next("label").parent().height() - Switchs.next("label").height()) / 2);
            /*---- 初始化 ----*/
            // 是否选中以input:checkbox的选中状态为准
            if ($switch.is(':checked') && !$switch.is(':disabled')) {
                $switch.next("label").addClass(options.checkedClass).removeClass(options.disabledClass);
            } else if (!$switch.is(':checked') && $switch.is(':disabled'))  {
                $switch.next("label").removeClass(options.checkedClass).addClass(options.disabledClass);
            } else if ($switch.is(':disabled') || $switch.is(':checked')) {
                $switch.next("label").addClass(options.disabledClass).addClass(options.checkedClass);
            } else if (!$switch.is(':checked') && !$switch.is(':disabled'))  {
                $switch.next("label").removeClass(options.checkedClass).removeClass(options.disabledClass);
            }

            /*---- 添加事件 ----*/
            $switch.on("change",
                function() {
                    $(this).next("label").toggleClass(options.checkedClass);
                    options.onChange($(this)[0].checked); // 回调
                });
        });
    };
}(jQuery));

/*-----------------------------------------------Andrew_Substring-------------------------------------------*/
(function($){
    $.fn.Andrew_Substring = function() {
        $(this).blur(function() {
            this.value = outputmoney(this.value);
        });
    };
    //金额字符串设置
    function outputdollars(number) {
        if (number.length <= 3) return (number == '' ? '0': number);
        else {
            var mod = number.length % 3;
            var output = (mod == 0 ? '': (number.substring(0, mod)));
            for (var i = 0; i < Math.floor(number.length / 3); i++) {
                if ((mod == 0) && (i == 0)) output += number.substring(mod + 3 * i, mod + 3 * i + 3);
                else output += '' + number.substring(mod + 3 * i, mod + 3 * i + 3);
            }
            return (output);
        }
    }
    function outputcents(amount) {
        amount = Math.round(((amount) - Math.floor(amount)) * 100);
        return (amount < 10 ? '.0' + amount: '.' + amount);
    }
    //金额字符格式化（RMB）
    function outputmoney(number) {
        number = number.replace(/\,/g, "");
        if (isNaN(number) || number == "") return "";
        number = Math.round(number * 100) / 100;
        if (number < 0) return '-' + outputdollars(Math.floor(Math.abs(number) - 0) + '') + outputcents(Math.abs(number) - 0);
        else return outputdollars(Math.floor(number - 0) + '') + outputcents(number - 0);
    }
}(jQuery));

/*-----------------------------------------------Andrew_PreviewImage-------------------------------------------*/
(function($){
    var option = {};
    $.fn.Andrew_PreviewImage = function(setting) {

        var op = $.extend({
                uploadNum:0,//用于计算图片上传数量
                webToast: "",
                messege: "",
                btn_ok: "",
                btn_cancel: "",
                box_title: new Array(
                    "confirm",
                    "alert"
                ),
                Class:"",
                Del_icon:"",
                length:"",
                length_title:"",
                errorTip:"",
                addCallbak: function() {},
                delCallbak: function() {}
            },
            setting);
        option = op;
        var pimg = $(this);
        pimg.addClass("ak-previewImage " + op.Class);
        pimg.find("input[type=file]").attr("accept","image/*");
        pimg.bind('change',
            function() {
                if(op.uploadNum == op.length){
                    webToast(op.length_title +""+ op.length+"","middle","mask",5000);
                    return false;
                }
                var tempData = $(this).children('input')[0];
                if((op.uploadNum + tempData.files.length) > op.length){
                    webToast(op.length_title +""+ op.length+"","middle","mask",5000);
                }
                var tempFiles = [];
                for(var i=0;i<(op.length-op.uploadNum);i++){
                    tempFiles.push(tempData.files[i])
                }
                file_prvid(tempData, tempFiles, op);
            });
        var figure_wh = $(this).outerWidth();
        var figure_m = $(this).outerWidth() / 3;
        pimg.children("figure").css({
            "width": figure_wh - figure_m,
            "height": figure_wh - figure_m,
            "line-height": figure_wh - figure_m+"px",
            "margin-top": (figure_m / 2)-2
        });
    };
    function file_prvid(file,files,op) {
        /* file：file控件
         * prvid: 图片预览容器
         */
        var tip = op.errorTip; // 设定提示信息
        var filters = {
            "jpeg": "/9j/4",
            "gif": "R0lGOD",
            "png": "iVBORw"
        }
        if (window.FileReader) { // html5方案
            for (var i = 0,f; f = files[i];i++) {

                //console.log(i);
                var fr = new FileReader();
                fr.onload = function(e) {
                    var src = e.target.result;
                    if (!Andrew_ValidateImg(src)) {
                        $ak.alert(tip, {
                            icon: "error",
                            button_ok: op.btn_ok,
                            button_cancel: op.btn_cancel,
                            title: op.box_title[1]
                        });
                        return false;
                    } else {
                        showPrvImg(src, file);
                        op.uploadNum ++;
                    }
                };
                fr.readAsDataURL(f);
            }
        } else { // 降级处理
            if (!/\.jpg$|\.png$|\.gif$/i.test(file.value)) {
                $ak.alert(tip, {
                    icon: "error",
                    button_ok: op.btn_ok,
                    button_cancel: op.btn_cancel,
                    title: op.box_title[1]
                });
                return false;
            } else {
                showPrvImg(file.value, file);
                op.uploadNum ++;
            }
        }
        function Andrew_ValidateImg(data) {
            var pos = data.indexOf(",") + 1;
            for (var e in filters) {
                if (data.indexOf(filters[e]) === pos) {
                    return e;
                }
            }
            return null;
        }
        function showPrvImg(src, id) {
            //上传图片后继续生成图片
            var imgList = "<li class='rel fl mb_5'>" +
                "<figure class='"+option.Class+"' style='background-color: #eeeeee !important;'>" +
                "<img class='w_100 left_0 abs' src=" + src + ">" +
                "</figure>" +
                "<span class='pointer top_0 abs wh_12em line_h_12em text_14em text_al_c bor_rad_50 c_white "+option.Del_icon+"' style='background-color: rgba(255,0,0,1); z-index: 1'>" +
                "</span>" +
                "</li>";
            $(id).parents("li").before(imgList);
            var showPrvImg_li = $(id).parents("li");

            option.addCallbak(showPrvImg_li.parent());
            showPrvImg_li.parent().find("li span").css({
                "margin-top": "-" + showPrvImg_li.parent().find("span").height() / 3 + "px",
                "left": showPrvImg_li.parent().find("figure").width() - (showPrvImg_li.parent().find("span").width() / 2)
            });
            showPrvImg_li.parent().find("li span").click(function(){
                var image = $(this);
                $ak.confirm(option.messege, {
                    icon: "question", //图标类型（warning，error，info，question，success）
                    button_ok: option.btn_ok,
                    button_cancel: option.btn_cancel,
                    title: option.box_title[0], //弹窗标题
                    onSubmit:function(res){
                        //image.parent("li").remove();
                        option.delCallbak(image.parent("li"));
                        op.uploadNum--;
                        webToast(option.webToast,"bottom",1000); //(提示文字，显示位置，耗时)
                    }
                });
            });
        }
    }
}(jQuery));

/*-----------------------------------------------Andrew_GetVerifyCode-------------------------------------------*/
(function($){
    /*constructor {} 计时按钮构造函数*/
    function Andrew_GetVerifyCode(){}
    /*倒计时 param { options: object } [必填] 倒计时所需的参数*/
    Andrew_GetVerifyCode.prototype.SecondCountDown = function (options) {
        var countDown = {};
        countDown.options = {
            time: 60,//总时间
            progress: function () { },//计时正在进行中
            started: function () { },//计时开始
            breaked: function () { },//计时中断
            end: function (){}//计时结束
        }
        for (var i in options) {
            countDown.options[i] = options[i];
        }
        countDown.timer = null;//存储计时器
        countDown.time = 0;//当前时间
        countDown._continueRun = true;//是否继续

        //开始计时
        countDown.start = function () {
            var that = this,
                time = that.options.time || 60,
                count = 0,//记录定时器执行了多少次
                interval = 1000,//每次执行间隔
                start = new Date().getTime(),//开始执行时间
                targetTime = that.options.time * 1000;//目标时间
            clearTimeout(that.timer);

            if (that.options.started && (({}).toString.call(that.options.started) == "[object Function]")) {
                that.options.started(time);
            }
            this._continueRun = true;
            that.timer = setTimeout(function () {
                if (that._continueRun) {
                    var wucha = 0,//计算误差
                        //下一次执行时间,下一次执行时间 = 每次执行间隔 - 误差
                        nextRunTime = interval,
                        currentFn = arguments.callee;
                    count++;
                    wucha = new Date().getTime() - (start + count * interval);
                    wucha = (wucha <= 0) ? 0 : wucha;
                    nextRunTime = interval - wucha;
                    nextRunTime = (nextRunTime <= 0) ? 0 : nextRunTime;


                    time--;
                    //在外部可以获取到倒计时当前时间
                    if (that.options.progress && (({}).toString.call(that.options.progress) == "[object Function]")) {
                        that.options.progress(time);
                    }
                    that.time = time;
                    that.timer = setTimeout(currentFn, nextRunTime);

                    //console.log("误差：" + wucha + "，下一次执行时间：" + nextRunTime);
                    if ((targetTime -= interval) <= 0) {
                        clearTimeout(that.timer);
                        /*time = 60;*/
                        if (that.options.end && (({}).toString.call(that.options.end) == "[object Function]")) {
                            that.options.end(time);
                        }
                        that.time = time;
                        return;
                    }
                } else {
                    clearTimeout(that.timer);
                }
            }, interval);
        }
        //中断计时
        countDown.abort = function () {
            this._continueRun = false;
            clearTimeout(this.timer);
            this.time--;
            if (this.options.breaked && (({}).toString.call(this.options.breaked) == "[object Function]")) {
                this.options.breaked(this.time);
            }
        }
        return countDown;
    }
    /*按钮倒计时功能，如发送验证码按钮
        param { eles: dom、jQuery object } [必填] 发送验证码的按钮
        param { options: object } [必填] 发送验证码相关配置
    */
    Andrew_GetVerifyCode.prototype.verify = function (eles,options) {
        eles = $(eles);
        if (eles.length > 0) {
            var self = this,
                timedown = {},
                verifyObj = {},
                _options = {
                    time: 60,
                    event: "click",
                    phone: "",
                    ableClass: "c_title",//按钮可以使用时的class
                    unableClass: "c_gray_999",//按钮不能使用时的class
                    condition: function () { },//执行条件，若condition为true则会执行
                    progress: function () { },//计时正在进行中时的回调
                    timeUp: function () { },//计时结束时执行的回调
                    abort: function () { },//中断计时
                    eventFn: function () { }//事件执行后的回调
                }
            $.extend(_options, options);
            eles.on(_options.event, function () {
                if (this.unabled) {
                    return;
                }
                var canRun = true,
                    phone = _options.phone;
                if ($.isFunction(_options.condition)) {
                    canRun = _options.condition.call(this,phone);
                } else {
                    canRun = _options.condition(phone);
                }
                if (!canRun) {
                    return;
                }

                var that = this,
                    $this = $(that);
                timedown = self.SecondCountDown({
                    time: _options.time,
                    progress: function (time) {
                        _options.progress.call(that,time,phone);
                    },
                    end: function (time) {
                        that.unabled = false;
                        $this.removeClass(_options.unableClass);
                        $this.addClass(_options.ableClass);
                        _options.timeUp.call(that,time,phone);
                    },
                    breaked: function (time) {
                        that.unabled = false;
                        $this.removeClass(_options.unableClass);
                        $this.addClass(_options.ableClass);
                        _options.abort.call(that,time,phone);
                    }
                });
                timedown.start();
                this.timedown = timedown;
                that.unabled = true;
                $this.removeClass(_options.ableClass);
                $this.addClass(_options.unableClass);
                _options.eventFn.call(this,phone);
            });
        }
    };
    window.Andrew_GetVerifyCode = new Andrew_GetVerifyCode();
}(jQuery));

/*-----------------------------------------------Andrew_NowTime-------------------------------------------*/
(function($){
    $.fn.Andrew_NowTime = function(setting) {
        var option = $.extend({
                dateStyle: 'yyyy-MM-dd hh:mm:ss',
            },
            setting);
        var time = this;
        Date.prototype.Format = function (fmt) {
            var o = {
                "M+": this.getMonth() + 1,
                "d+": this.getDate(),
                "h+": this.getHours(),
                "m+": this.getMinutes(),
                "s+": this.getSeconds()
            };
            if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o)
                if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            return fmt;
        };
        setInterval(function(){
            time.html(new Date().Format(option.dateStyle));
        },1000);
    };
}(jQuery));

/*-----------------------------------------------Andrew_Form-------------------------------------------*/
(function($){
    $.fn.Andrew_Form = function(setting) {
        var option = $.extend({
                btn_delete: "",
                btn_delete_ico: "",
                btn_password: "",
                btn_password_ico_hide: "",
                btn_password_ico_show: "",
                placeholder: true,
                keyboard: true,
                passchek: "",
                passCallback: function() {},
                butCallback: function() {}
            },
            setting);
        var mbf = $(this);

        //对比两次输入的密码
        var password = mbf.find(option.passchek);
        mbf.find(":submit").click(function () {
            if(password.length > 1){
                if (password[0].value != password[1].value){
                    if ($(this).parents("form").find(option.passchek).length > 0) {
                        option.passCallback();
                        return false;
                    }
                }
            }
            option.butCallback($(this).parents("form"));
        });

        //密码（显示/隐藏）
        var btn_password = mbf.find(option.btn_password);
        btn_password.each(function(){
            if ($(this).next("button").length < 1) {
                $(this).after("<button type=\"button\" class=\"press top_0 left_0 abs text_al_r text_18em c_gray_ccc\"></button>");
                $(this).next("button").addClass(option.btn_password_ico_hide)
                $(this).next("button").css({
                    "height": btn_password.outerHeight(),
                    "margin-top": (btn_password.height() - $(this).next("button").height()) / 2,
                    "margin-left": $(this).width() - $(this).next("button").width() -10
                });
            }
            $(this).next("button").click(function() {
                $(this).toggleClass(option.btn_password_ico_hide+" "+option.btn_password_ico_show);
                if ($(this).hasClass(option.btn_password_ico_show)) {
                    $(this).prev("input").attr("type","text");
                } else {
                    $(this).prev("input").attr("type","password");
                }
            });

        });
        //输入的文字删除按钮
        var btn_delete = mbf.find(option.btn_delete);
        btn_delete.bind('input propertychange', function() {
            if ($(this).val() > 0 ) {
                if ($(this).next("button[type=reset]").length < 1) {
                    $(this).after("<button type=\"reset\" class='top_0 left_0 abs press'><i class='fr bg_gray_ccc c_white bor_rad_50 wh_18em line_h_18em text_08em text_al_c text_18em'></i></button>");
                    $(this).next("button[type=reset]").css({
                        "height": $(this).prev("input").outerHeight(),
                        "margin-top": ($(this).height() - $(this).next("button[type=reset]").height()) / 2,
                        "margin-left": $(this).width() - $(this).next("button[type=reset]").width() -10
                    });
                    $(this).next("button[type=reset]").children("i").addClass(option.btn_delete_ico);
                }
                $(this).next("button[type=reset]").click(function() {
                    $(this).prev("input").val("");
                    $(this).remove();
                });
            } else {
                $(this).next("button[type=reset]").remove();
            }
        });

        if(option.placeholder== true) {
            var placeholder_tmp ="";
            mbf.find('*[placeholder]').focus(function() { //input元素加placeholder属性的文字点击后消失
                placeholder_tmp = $(this).attr("placeholder");
                $(this).removeAttr('placeholder');
                $(this).blur(function() {
                    $(this).attr("placeholder",placeholder_tmp);
                });
            });
            var isIE = function () {
                var U = navigator.userAgent,
                    IsIE = U.indexOf('MSIE') > -1,
                    a = IsIE ? /\d+/.exec(U.split(';')[1]) : 'no ie';return a <= 9;
            }();
            if(isIE){  //解决IE浏览器不支持input元素中的placeholder属性
                $("input").each(function(){
                    $(this).css("lineHeight",$(this).height()+"px");
                });
                mbf.find('*[placeholder]').each(function(){
                    if ($(this)[0].type != "password") {
                        $(this).attr("value",$(this).attr('placeholder'));
                        $(this).attr("onblur","if(this.value==''){this.value='"+$(this).attr("placeholder")+"'}");
                        $(this).attr("onfocus","if(this.value=='"+$(this).attr("placeholder")+"'){this.value=''}");
                    }
                });
            }
        }
        if(option.keyboard== true) {
            mbf.find("*[readonly]").focus(function(){ //input元素加readonly属性不显示键盘
                document.activeElement.blur();//隐藏键盘
            });
            mbf.find("*[maxlength]").each(function(){ //input元素加maxlength属性后控制自定义字数
                $(this).attr("oninput",'if(value.length>'+$(this).attr("maxlength")+')value=value.slice(0,'+$(this).attr("maxlength")+')');
                $(this).on('input',function(){
                    var maxlength = $(this).val();
                    if(maxlength.length == $(this).attr("maxlength")) { //输入自定的限制字数后手机键盘自动消失
                        document.activeElement.blur();//隐藏键盘
                    }
                });
            });
        }
    };
}(jQuery));

/*-----------------------------------------------Andrew_AllChecked-------------------------------------------*/
(function($){
    $.fn.Andrew_AllChecked = function(setting) {
        var option = $.extend({
                chk_Default_Class: "bor_gray_ddd",
                chk_Active_Class: "bg_title bor_title iconfont icon-wancheng c_white",
                btn_Default_Class: "bg_orange c_white",
                btn_Active_Class: "bg_gray_eee c_gray_777",
                callback :function(){}
            },
            setting);
        var AllChecked = this;
        var allchk = AllChecked.children("li").children("dl").children("dt").find(":checkbox");
        var allchk_btn = AllChecked.find("button");
        if (allchk_btn.length > 0) {
            allchk_btn.addClass(option.btn_Default_Class)
        }
        allchk.click(function() {
            var CheckedList = $(this).parent("label").parent("dt").parent("dl").next("ul");
            var chk_input = CheckedList.find("li :checkbox");
            var chk_label = CheckedList.find("li label");
            var carChecked = [];
            if (this.checked) {
                chk_label.addClass(option.chk_Active_Class);
                chk_label.removeClass(option.chk_Default_Class);
                chk_input.prop('checked', true);
                $(this).prop('checked', true);
            } else {
                chk_label.removeClass(option.chk_Active_Class);
                chk_label.addClass(option.chk_Default_Class);
                chk_input.prop('checked', false);
                $(this).prop('checked', false);
            }
            allchk_btn.removeClass(option.btn_Default_Class);
            allchk_btn.addClass(option.btn_Active_Class);
            var flag = false;
            allchk_btn.next("ul").find("li :checkbox").each(function () {
                if($(this)[0].checked){
                    flag = true;
                }
            });
            if(flag){
                allchk_btn.removeClass(option.btn_Default_Class);
                allchk_btn.addClass(option.btn_Active_Class);
                allchk_btn.next("ul").find("li :checkbox").each(function () {
                    carChecked.push($(this)[0].checked);
                })
            }else{
                allchk_btn.addClass(option.btn_Default_Class);
                allchk_btn.removeClass(option.btn_Active_Class);
                allchk_btn.next("ul").find("li :checkbox").each(function () {
                    carChecked.push(true);
                })
            }
            option.callback(carChecked);
        });
        allchk_btn.click(function() {
            var CheckedList = $(this).next("ul");
            var chk_input = CheckedList.find("li :checkbox");
            var chk_label = CheckedList.find("li label");
            var carChecked = [];
            chk_label.removeClass(option.chk_Active_Class);
            chk_label.addClass(option.chk_Default_Class);
            $(this).addClass(option.btn_Default_Class);
            $(this).removeClass(option.btn_Active_Class);
            chk_input.removeAttr("checked");
            allchk_btn.next("ul").find("li :checkbox").each(function () {
                $(this)[0].checked = false;
                carChecked.push(true);
            });
            option.callback(carChecked);
        });
    };
}(jQuery));

/*-----------------------------------------------Andrew_DropUpDown-------------------------------------------*/
(function($){
    $.fn.Andrew_DropUpDown = function(setting) {
        var option = $.extend({
                curDisplay: "",
                active_toggle: "",
                up_ico: "",
                down_ico: "",
                callback:function(){}
            },
            setting);
        function DropDown(el) {
            this.DropUpDown = el;
            this.initEvents();
        }
        DropDown.prototype = {
            initEvents: function() {
                var obj = this;
                var drop = obj.DropUpDown.children("dl").children("dd:last-child");
                if (option.curDisplay) {
                    var ele_display = obj.DropUpDown.eq(option.curDisplay-1);
                    ele_display.addClass("ak-is_active");
                    ele_display.children("dl").addClass(option.active_toggle);
                    ele_display.children("dl").find("dd").last().children("i").removeClass(option.down_ico).addClass(option.up_ico);
                }
                drop.each(function () {
                    var alldrop = $(this).parent("dl").parent("li");
                    var alldropsub = alldrop.children("dl").next();
                    if (alldrop.hasClass("ak-is_active")) {
                        alldropsub.show();
                    } else {
                        alldropsub.hide();
                    }
                    alldropsub.find("li").addClass("ml_3");
                    alldrop.children("dl").find("dd").last().click(function () {
                        alldrop.toggleClass("ak-is_active");
                        if (alldrop.children("dl").next().length > 0) {
                            alldrop.children("dl").toggleClass(option.active_toggle);
                        }
                        alldrop.children("dl").find("dd").last().children("i").toggleClass(option.up_ico + " " + option.down_ico);
                        if (alldrop.hasClass("ak-is_active")) {
                            alldropsub.slideDown(300);
                            option.callback(alldropsub);
                        } else {
                            alldropsub.slideUp(300);
                        }
                    });
                });
            }
        };
        var drop = new DropDown($(this).children("li"));
    };
}(jQuery));

/*-----------------------------------------------Andrew_MemberUpDown-------------------------------------------*/
(function($){
    $.fn.Andrew_MemberUpDown = function(setting) {
        var option = $.extend({
                dom: ".",
                callback:function(){}
            },
            setting);
        function UpDown(el) {
            this.el = el;
            this.initEvents();
        }
        UpDown.prototype = {
            initEvents : function() {
                var obj = this;
                obj.el.each(function() {
                    var objsub = $(option.dom);
                    objsub.hide();
                    objsub.css({
                        "width": obj.el.outerWidth(),
                        "top": obj.el.offset().top + (obj.el.outerHeight()/1.2),
                        "left": obj.el.offset().left
                    });
                    $(this).on('click', function(event){
                        $(this).toggleClass('ak-is_active');
                        if ($(this).hasClass('ak-is_active')) {
                            objsub.slideDown();
                            option.callback(objsub);
                        } else {
                            objsub.slideUp();
                        }
                        event.stopPropagation();
                    });
                    $(document).click(function() {
                        obj.el.removeClass('ak-is_active');
                        objsub.slideUp();
                    });
                });
            }
        };
        var el = new UpDown( $(this) );
    };
}(jQuery));

/*-----------------------------------------------Andrew_HoverPopup-------------------------------------------*/
(function($){
    $.fn.Andrew_HoverPopup = function(setting) {
        var option = $.extend({
                popup_win: ".",
                popup_width: "auto",
                popup_height: "100%",
                duration: 300,
                easing: "easeInOutSine",
                callback:function(){}
            },
            setting);
        var obj = $(this);
        var objsub = $(option.popup_win);
        objsub.wrap("<div class='ak-HoverPopup'/>");
        objsub.parent().css({
            "padding-top": obj.outerHeight(),
            "width": option.popup_width,
            "top": obj.offset().top,
            "left": obj.offset().left
        });
        objsub.parent().mouseover(function(){
            objsub.stop().animate({
                height: option.popup_height,
                opacity:1
            },{
                queue: false,
                duration: option.duration,
                easing: option.easing
            });
            objsub.show();
            option.callback(objsub);
        });
        objsub.parent().mouseout(function(){
            objsub.stop().animate({
                height: 0,
                opacity:0
            },{
                queue: false,
                duration: option.duration,
                easing: option.easing
            });
        });
    };
}(jQuery));

/*-----------------------------------------------Andrew_InputSelect-------------------------------------------*/
(function($){
    $.fn.Andrew_InputSelect = function(setting) {
        var option = $.extend({
                dom: "",
                value:"",
                maxheight:"",
                clickBack:function(){
                }
            },
            setting);
        function InputSelect(el) {
            this.el = el;
            this.initEvents();
        }
        InputSelect.prototype = {
            initEvents : function() {
                var obj = this;
                obj.el.each(function() {
                    var objsub = $(option.dom);
                    objsub.hide();
                    objsub.css({
                        "width": obj.el.outerWidth(),
                        "top": obj.el.offset().top + obj.el.outerHeight(),
                        "left": obj.el.offset().left,
                        "max-height":option.maxheight,
                        "overflow-y": "auto"
                    });
                    option.value.css({
                        "cursor": "pointer"
                    });
                    option.value.hover(function(){
                        $(this).addClass("bg_gray_f5f");
                    },function(){
                        $(this).removeClass("bg_gray_f5f");
                    });
                    option.value.on('click', function(){
                        var val = this;
                        obj.el.val($(this).text());
                        objsub.slideUp();
                        option.clickBack(val);
                    });
                    $(this).on('click', function(event){
                        $(this).toggleClass('ak-is_active');
                        if ($(this).hasClass('ak-is_active')) {
                            objsub.slideDown();
                        } else {
                            objsub.slideUp();
                        }
                        event.stopPropagation();
                    });
                    //yuany添加 input value改变时（不需要失去焦点直接出发） - START
                    $(this).on('input', function() {
                        //console.log("input event :" + $(this).val());
                        $(this).addClass('ak-is_active');
                        objsub.delay(1000).slideDown();
                    });
                    //yuany添加 input value改变时（不需要失去焦点直接出发） - END
                    $(document).click(function() {
                        obj.el.removeClass('ak-is_active');
                        objsub.slideUp();
                    });
                });
            }
        };
        var el = new InputSelect( $(this) );
    };
}(jQuery));

/*-----------------------------------------------Andrew_Spinner-------------------------------------------*/
(function($){
    $.fn.Andrew_Spinner=function(setting) {
        var option = $.extend({
                input_width:"100%", //输入框宽度（px,%,em）
                btn_wrap: "fl rel ovh border h_36em bor_gray_ddd bg_white bor_rad_05em", //数量加减输入框的外框样式
                btn_left: "abs top_0 left_0 bor_right bor_gray_ddd bg_white w_25 text_18em c_gray_777", //数量减少按钮Class
                btn_right: "abs top_0 right_0 bor_left bor_gray_ddd bg_white w_25 text_18em c_gray_777", //数量增加按钮Class
                clickBack:function(){
                }
            },
            setting);
        var spt =$(this);
        spt.each(function(i) {
            spt.wrap('<div class="'+option.btn_wrap+'"></div>');
            spt.before('<button class="minus '+option.btn_left+'">-</button>');
            spt.before('<button class="plus '+option.btn_right+'">+</button>');
            var it =$(this).parent().find("input");
            $(this).parent().css({
                "width": option.input_width,
                "height": $(this).parent().children("button").height(),
                "margin-top": ($(this).parent().height() - $(this).parent().children("button").height()) / 2
            }).addClass("ovh");
            it.css({
                "width": "100%",
                "height": $(this).parent().children("button").height(),
                "line-height": "100%",
                "float": "inherit"
            });
            if (parseInt(it.val())<=1){
                $(this).parent().children(".minus").attr("disabled",'disabled');
            }
            $(this).parent().children(".plus").on('click', function (e) {
                e.preventDefault();
                var lengthNum= parseInt(it.val());
                it.val(parseInt(it.val())+1);
                $(this).parent().children(".minus").removeAttr("disabled",'disabled');
                option.clickBack(lengthNum+1)
            })
            $(this).parent().children(".minus").on('click', function (e) {
                e.preventDefault();
                var lengthNum= parseInt(it.val());
                it.val(parseInt(it.val())-1);
                if (parseInt(it.val())<=1){
                    it.val(parseInt(1));
                    $(this).attr("disabled",'disabled');
                }
                option.clickBack(lengthNum-1)
            })
        });
    }
}(jQuery));

/*-----------------------------------------------Andrew_CountTo-------------------------------------------*/
(function($){
    $.fn.Andrew_CountTo = function (options) {
        options = options || {};
        return $(this).each(function () {
            var settings = $.extend({}, $.fn.Andrew_CountTo.defaults, {
                from:            $(this).data('from'),
                to:              $(this).data('to'),
                speed:           $(this).data('speed'),
                refreshInterval: $(this).data('refresh-interval'),
                decimals:        $(this).data('decimals')
            }, options);

            // how many times to update the value, and how much to increment the value on each update
            var loops = Math.ceil(settings.speed / settings.refreshInterval),
                increment = (settings.to - settings.from) / loops;

            // references & variables that will change with each update
            var self = this,
                $self = $(this),
                loopCount = 0,
                value = settings.from,
                data = $self.data('Andrew_CountTo') || {};

            $self.data('Andrew_CountTo', data);

            // if an existing interval can be found, clear it first
            if (data.interval) {
                clearInterval(data.interval);
            }
            data.interval = setInterval(updateTimer, settings.refreshInterval);

            // initialize the element with the starting value
            render(value);

            function updateTimer() {
                value += increment;
                loopCount++;

                render(value);

                if (typeof(settings.onUpdate) == 'function') {
                    settings.onUpdate.call(self, value);
                }

                if (loopCount >= loops) {
                    // remove the interval
                    $self.removeData('Andrew_CountTo');
                    clearInterval(data.interval);
                    value = settings.to;

                    if (typeof(settings.onComplete) == 'function') {
                        settings.onComplete.call(self, value);
                    }
                }
            }

            function render(value) {
                var formattedValue = settings.formatter.call(self, value, settings);
                $self.html(formattedValue);
            }
        });
    };
    $.fn.Andrew_CountTo.defaults = {
        from: 0,               // the number the element should start at
        to: 0,                 // the number the element should end at
        speed: 1000,           // how long it should take to count between the target numbers
        refreshInterval: 100,  // how often the element should be updated
        decimals: 0,           // the number of decimal places to show
        formatter: formatter,  // handler for formatting the value before rendering
        onUpdate: null,        // callback method for every time the element is updated
        onComplete: null       // callback method for when the element finishes updating
    };
    function formatter(value, settings) {
        return value.toFixed(settings.decimals);
    }
}(jQuery));

/*-----------------------------------------------Andrew_Loader-------------------------------------------*/
(function($){
    $.fn.Andrew_Loader =function(option) {
        var defaultVal = {
            backgroudColor: "",//背景色
            backgroundImage: "",//背景图片
            text: "",//文字
            width: "",//宽度
            height: "",//高度
            time: "", //自动关闭秒数
            mask: true, //是否使用遮挡背景
            type: 0 //0全部遮，1 局部遮
        };
        var opt = $.extend({}, defaultVal, option);
        if (opt.type == 0) {
            //全屏遮
            ak_fullscreen_Layer();
        } else {
            //局部遮(当前对象应为需要被遮挡的对象)
            ak_element_Layer(this);
        }
        //销毁对象
        if (option === "destroy") {
            ak_closeLayer();
        }
        if (opt.time > 0) {
            //自动关闭
            setTimeout(function () {
                $.fn.Andrew_Loader("destroy");
            }, opt.time);
        }
        /*==========全部遮罩=========*/
        function ak_fullscreen_Layer() {
            //背景遮罩层
            var full_layer = $("<div class='ak-Loader-full_layer'></div>");
            full_layer.css({
                zIndex:99,
                position: "fixed",
                height: "100%",
                width: "100%",
                top: 0,
                left: 0,
            });
            if (opt.mask == true) {
                full_layer.addClass("ak-mask");
            }
            //图片及文字层
            var full_content = $("<div class='ak-Loader-full_content'></div>");
            full_content.css({
                textAlign: "center",
                position:"absolute",
                zIndex: 100,
                height: opt.height + "px",
                width: opt.width + "px",
                top: "45%",
                left: "50%",
                background: opt.backgroudColor,
                borderRadius:"0.5em",
                fontSize:"1.2em"
            });
            full_content.append("<img style='margin:"+(opt.height/4)+"px 0.5em 0 1em;' src='" + opt.backgroundImage + "' /><span style='line-height:" + opt.height + "px;'>" + opt.text + "</span>");
            if ($(".ak-Loader-full_layer").length < 1) {
                $("body").append(full_layer);
                full_layer.append(full_content);
            }
            var top = full_content.css("top").replace('px','');
            var left = full_content.css("left").replace('px','');
            full_content.css("top",(parseFloat(top)-opt.height/2)).css("left",(parseFloat(left)-opt.width/2));
            return this;
        }
        //销毁对象
        function ak_closeLayer() {
            $(".ak-Loader-full_layer,.ak-Loader-full_content,.ak-Loader-ele_layer,.ak-Loader-ele_content").remove();
            return this;
        }
        /*==========局部遮罩=========*/
        function ak_element_Layer(obj) {
            var eheight = $(obj).css("height");//元素带px的高宽度
            var ewidth = $(obj).css("width");
            var top = $(obj).offset().top; // 元素在文档中位置 滚动条不影响
            var left = $(obj).offset().left;
            //背景遮罩层
            var ele_layer = $("<div class='ak-Loader-ele_layer'></div>");
            ele_layer.css({
                zIndex: 99,
                position: "absolute",
                height: eheight,
                width: ewidth,
                top: top,
                left: left,
                dispaly: "block"
            });
            if (opt.mask == true) {
                ele_layer.addClass("ak-mask");
            }
            //图片及文字层
            var ele_content = $("<div class='ak-Loader-ele_content'></div>");
            ele_content.css({
                textAlign: "center",
                position:"absolute",
                zIndex: 100,
                height: opt.height + "px",
                width: opt.width + "px",
                top: (ele_layer.outerHeight()/2)-(opt.height/2),
                left: (ele_layer.outerWidth()/2)-(opt.width/2),
                background: opt.backgroudColor,
                borderRadius:"0.5em",
                fontSize:"1.2em"
            });
            ele_content.append("<img style='margin:"+(opt.height/4)+"px 0.5em 0 1em;' src='" + opt.backgroundImage + "' /><span style='line-height:" + opt.height + "px;'>" + opt.text + "</span>");
            if ($(".ak-Loader-ele_layer").length < 1) {
                $("body").append(ele_layer);
                ele_layer.append(ele_content);
            }
            return this;
        }
    }
}(jQuery));

/*-----------------------------------------------Andrew_Select-------------------------------------------*/
(function($){
    var defaluts = {
        select: "ak-select",
        select_text: "ak-select_text",
        select_list: "ak-select_list",
        select_name:""
    };
    $.fn.extend({
        "Andrew_Select": function(options){
            var opts = $.extend({
                callback: function() {}
            }, defaluts, options);
            return this.each(function(){
                var $this = $(this);
                if ($this.data("value") !== undefined && $this.data("value") !== '') {
                    $this.val($this.data("value"));
                }
                $this.addClass(opts.select);
                var _html = [];
                _html.push("<div class=\"" + $this.attr('class') + "\">");
                _html.push("<div class=\""+ opts.select_text +"\">" + $this.find(":selected").text() + "</div>");
                _html.push("<div class=\""+ opts.select_list +"\"><ul class='bg_white08'>");
                $this.children("option").each(function () {
                    var option = $(this);
                    if($this.data("value") == option.val()){
                        _html.push("<li class=\"line_h_3em bg_title c_white\" data-value=\"" + option.val() + "\">" + option.text() + "</li>");
                    }else{
                        _html.push("<li class=\"line_h_3em\" data-value=\"" + option.val() + "\">" + option.text() + "</li>");
                    }
                });
                _html.push("</ul>");
                _html.push("</div>");
                _html.push("</div>");
                var select = $(_html.join(""));
                var select_text = select.find("." + opts.select_text);
                var select_list = select.find("." + opts.select_list);
                $this.after(select);
                $('body').append(select_list);
                select_list.addClass(opts.select_name).attr("id",opts.select_name);
                $this.hide();
                select.click(function (event) {
                    $(this).toggleClass("open");
                    select_list.css({
                        "width": select.innerWidth() + 2,
                        "top": select.offset().top + select.innerHeight()+1,
                        "left": select.offset().left
                    });
                    select_list.slideToggle();
                    event.stopPropagation();
                });
                $("body").click(function () {
                    select_list.slideUp();
                    select.removeClass("open");
                });
                select_list.on("click", "li", function () {
                    var li = $(this);
                    var val = li.addClass("bg_title c_white").siblings("li").removeClass("bg_title c_white").end().data("value").toString();
                    select.removeClass("open");
                    if (val !== $this.val()) {
                        select_text.text(li.text());
                        $this.val(val);
                        $this.attr("data-value",val);
                        $this.find("option[value!='"+val+"']").removeAttr("selected");
                        $this.find("option[value='"+val+"']").attr("selected","selected");
                        $this.change();
                        opts.callback(val);
                    }
                });
            });
        }
    });
}(jQuery));

/*-----------------------------------------------Andrew_Ratyli-------------------------------------------*/
(function($){
    var methods = {
        init: function(settings) {
            return this.each(function() {
                methods.destroy.call(this);

                this.opt = $.extend(true, {}, $.fn.Andrew_Ratyli.defaults, settings);

                var that  = $(this),
                    inits = ['number', 'readOnly', 'score', 'scoreName'];

                methods._callback.call(this, inits);

                if (this.opt.precision) {
                    methods._adjustPrecision.call(this);
                }

                this.opt.number = methods._between(this.opt.number, 0, this.opt.numberMax)

                this.opt.path = this.opt.path || '';

                if (this.opt.path && this.opt.path.slice(this.opt.path.length - 1, this.opt.path.length) !== '/') {
                    this.opt.path += '/';
                }

                this.stars = methods._createStars.call(this);
                this.score = methods._createScore.call(this);

                methods._apply.call(this, this.opt.score);

                var space  = this.opt.space ? 4 : 0,
                    width  = this.opt.width || (this.opt.number * this.opt.size + this.opt.number * space);

                if (this.opt.cancel) {
                    this.cancel = methods._createCancel.call(this);

                    width += (this.opt.size + space);
                }

                if (this.opt.readOnly) {
                    methods._lock.call(this);
                } else {
                    that.css('cursor', 'pointer');
                    methods._binds.call(this);
                }

                if (this.opt.width !== false) {
                    that.css('width', width);
                }

                methods._target.call(this, this.opt.score);

                that.data({ 'settings': this.opt, 'Andrew_Ratyli': true });
            });
        }, _adjustPrecision: function() {
            this.opt.targetType = 'score';
            this.opt.half       = true;
        }, _apply: function(score) {
            if (score && score > 0) {
                score = methods._between(score, 0, this.opt.number);
                this.score.val(score);
            }

            methods._fill.call(this, score);

            if (score) {
                methods._roundStars.call(this, score);
            }
        }, _between: function(value, min, max) {
            return Math.min(Math.max(parseFloat(value), min), max);
        }, _binds: function() {
            if (this.cancel) {
                methods._bindCancel.call(this);
            }

            methods._bindClick.call(this);
            methods._bindOut.call(this);
            methods._bindOver.call(this);
        }, _bindCancel: function() {
            methods._bindClickCancel.call(this);
            methods._bindOutCancel.call(this);
            methods._bindOverCancel.call(this);
        }, _bindClick: function() {
            var self = this,
                that = $(self);

            self.stars.on('click.Andrew_Ratyli', function(evt) {
                self.score.val((self.opt.half || self.opt.precision) ? that.data('score') : this.alt);

                if (self.opt.click) {
                    self.opt.click.call(self, parseFloat(self.score.val()), evt);
                }
            });
        }, _bindClickCancel: function() {
            var self = this;

            self.cancel.on('click.Andrew_Ratyli', function(evt) {
                self.score.removeAttr('value');

                if (self.opt.click) {
                    self.opt.click.call(self, null, evt);
                }
            });
        }, _bindOut: function() {
            var self = this;

            $(this).on('mouseleave.Andrew_Ratyli', function(evt) {
                var score = parseFloat(self.score.val()) || undefined;

                methods._apply.call(self, score);
                methods._target.call(self, score, evt);

                if (self.opt.mouseout) {
                    self.opt.mouseout.call(self, score, evt);
                }
            });
        }, _bindOutCancel: function() {
            var self = this;

            self.cancel.on('mouseleave.Andrew_Ratyli', function(evt) {
                $(this).attr('src', self.opt.path + self.opt.cancelOff);

                if (self.opt.mouseout) {
                    self.opt.mouseout.call(self, self.score.val() || null, evt);
                }
            });
        }, _bindOverCancel: function() {
            var self = this;

            self.cancel.on('mouseover.Andrew_Ratyli', function(evt) {
                $(this).attr('src', self.opt.path + self.opt.cancelOn);

                self.stars.attr('src', self.opt.path + self.opt.starOff);

                methods._target.call(self, null, evt);

                if (self.opt.mouseover) {
                    self.opt.mouseover.call(self, null);
                }
            });
        }, _bindOver: function() {
            var self   = this,
                that   = $(self),
                action = self.opt.half ? 'mousemove.Andrew_Ratyli' : 'mouseover.Andrew_Ratyli';

            self.stars.on(action, function(evt) {
                var score = parseInt(this.alt, 10);

                if (self.opt.half) {
                    var position = parseFloat((evt.pageX - $(this).offset().left) / self.opt.size),
                        plus     = (position > .5) ? 1 : .5;

                    score = score - 1 + plus;

                    methods._fill.call(self, score);

                    if (self.opt.precision) {
                        score = score - plus + position;
                    }

                    methods._roundStars.call(self, score);

                    that.data('score', score);
                } else {
                    methods._fill.call(self, score);
                }

                methods._target.call(self, score, evt);

                if (self.opt.mouseover) {
                    self.opt.mouseover.call(self, score, evt);
                }
            });
        }, _callback: function(options) {
            for (i in options) {
                if (typeof this.opt[options[i]] === 'function') {
                    this.opt[options[i]] = this.opt[options[i]].call(this);
                }
            }
        }, _createCancel: function() {
            var that   = $(this),
                icon   = this.opt.path + this.opt.cancelOff,
                cancel = $('<img />', { src: icon, alt: 'x', width: this.opt.iconsize, height: this.opt.iconsize, title: this.opt.cancelHint});

            if (this.opt.cancelPlace == 'left') {
                that.prepend(' ').prepend(cancel);
            } else {
                that.append(' ').append(cancel);
            }

            return cancel;
        }, _createScore: function() {
            return $('<input />', { type: 'hidden', name: this.opt.scoreName }).appendTo(this);
        }, _createStars: function() {
            var that = $(this);

            for (var i = 1; i <= this.opt.number; i++) {
                var title = methods._getHint.call(this, i),
                    icon  = (this.opt.score && this.opt.score >= i) ? 'starOn' : 'starOff';

                icon = this.opt.path + this.opt[icon];

                $('<img />', { src : icon, alt: i, width: this.opt.iconsize, height: this.opt.iconsize, title: title }).appendTo(this);

                if (this.opt.space) {
                    that.append((i < this.opt.number) ? ' ' : '');
                }
            }

            return that.children('img');
        }, _error: function(message) {
            $(this).html(message);

            $.error(message);
        }, _fill: function(score) {
            var self  = this,
                hash  = 0;

            for (var i = 1; i <= self.stars.length; i++) {
                var star   = self.stars.eq(i - 1),
                    select = self.opt.single ? (i == score) : (i <= score);

                if (self.opt.iconRange && self.opt.iconRange.length > hash) {
                    var irange = self.opt.iconRange[hash],
                        on     = irange.on  || self.opt.starOn,
                        off    = irange.off || self.opt.starOff,
                        icon   = select ? on : off;

                    if (i <= irange.range) {
                        star.attr('src', self.opt.path + icon);
                    }

                    if (i == irange.range) {
                        hash++;
                    }
                } else {
                    var icon = select ? 'starOn' : 'starOff';

                    star.attr('src', this.opt.path + this.opt[icon]);
                }
            }
        }, _getHint: function(score) {
            var hint = this.opt.hints[score - 1];
            return (hint === '') ? '' : (hint || score);
        }, _lock: function() {
            var score = parseInt(this.score.val(), 10), // TODO: 3.1 >> [['1'], ['2'], ['3', '.1', '.2']]
                hint  = score ? methods._getHint.call(this, score) : this.opt.noRatedMsg;

            $(this).data('readonly', true).css('cursor', '').attr('title', hint);

            this.score.attr('readonly', 'readonly');
            this.stars.attr('title', hint);

            if (this.cancel) {
                this.cancel.hide();
            }
        }, _roundStars: function(score) {
            var rest = (score - Math.floor(score)).toFixed(2);

            if (rest > this.opt.round.down) {
                var icon = 'starOn';                                 // Up:   [x.76 .. x.99]

                if (this.opt.halfShow && rest < this.opt.round.up) { // Half: [x.26 .. x.75]
                    icon = 'starHalf';
                } else if (rest < this.opt.round.full) {             // Down: [x.00 .. x.5]
                    icon = 'starOff';
                }

                this.stars.eq(Math.ceil(score) - 1).attr('src', this.opt.path + this.opt[icon]);
            }                              // Full down: [x.00 .. x.25]
        }, _target: function(score, evt) {
            if (this.opt.target) {
                var target = $(this.opt.target);

                if (target.length === 0) {
                    methods._error.call(this, 'Target selector invalid or missing!');
                }

                if (this.opt.targetFormat.indexOf('{score}') < 0) {
                    methods._error.call(this, 'Template "{score}" missing!');
                }

                var mouseover = evt && evt.type == 'mouseover';

                if (score === undefined) {
                    score = this.opt.targetText;
                } else if (score === null) {
                    score = mouseover ? this.opt.cancelHint : this.opt.targetText;
                } else {
                    if (this.opt.targetType == 'hint') {
                        score = methods._getHint.call(this, Math.ceil(score));
                    } else if (this.opt.precision) {
                        score = parseFloat(score).toFixed(1);
                    }

                    if (!mouseover && !this.opt.targetKeep) {
                        score = this.opt.targetText;
                    }
                }

                if (score) {
                    score = this.opt.targetFormat.toString().replace('{score}', score);
                }

                if (target.is(':input')) {
                    target.val(score);
                } else {
                    target.html(score);
                }
            }
        }, _unlock: function() {
            $(this).data('readonly', false).css('cursor', 'pointer').removeAttr('title');

            this.score.removeAttr('readonly', 'readonly');

            for (var i = 0; i < this.opt.number; i++) {
                this.stars.eq(i).attr('title', methods._getHint.call(this, i + 1));
            }

            if (this.cancel) {
                this.cancel.css('display', '');
            }
        }, cancel: function(click) {
            return this.each(function() {
                if ($(this).data('readonly') !== true) {
                    methods[click ? 'click' : 'score'].call(this, null);
                    this.score.removeAttr('value');
                }
            });
        }, click: function(score) {
            return $(this).each(function() {
                if ($(this).data('readonly') !== true) {
                    methods._apply.call(this, score);

                    if (!this.opt.click) {
                        methods._error.call(this, 'You must add the "click: function(score, evt) { }" callback.');
                    }

                    this.opt.click.call(this, score, { type: 'click' });

                    methods._target.call(this, score);
                }
            });
        }, destroy: function() {
            return $(this).each(function() {
                var that = $(this),
                    raw  = that.data('raw');

                if (raw) {
                    that.off('.Andrew_Ratyli').empty().css({ cursor: raw.style.cursor, width: raw.style.width }).removeData('readonly');
                } else {
                    that.data('raw', that.clone()[0]);
                }
            });
        }, getScore: function() {
            var score = [],
                value ;

            $(this).each(function() {
                value = this.score.val();

                score.push(value ? parseFloat(value) : undefined);
            });

            return (score.length > 1) ? score : score[0];
        }, readOnly: function(readonly) {
            return this.each(function() {
                var that = $(this);

                if (that.data('readonly') !== readonly) {
                    if (readonly) {
                        that.off('.Andrew_Ratyli').children('img').off('.Andrew_Ratyli');

                        methods._lock.call(this);
                    } else {
                        methods._binds.call(this);
                        methods._unlock.call(this);
                    }

                    that.data('readonly', readonly);
                }
            });
        }, reload: function() {
            return methods.set.call(this, {});
        }, score: function() {
            return arguments.length ? methods.setScore.apply(this, arguments) : methods.getScore.call(this);
        }, set: function(settings) {
            return this.each(function() {
                var that   = $(this),
                    actual = that.data('settings'),
                    news   = $.extend({}, actual, settings);

                that.Andrew_Ratyli(news);
            });
        }, setScore: function(score) {
            return $(this).each(function() {
                if ($(this).data('readonly') !== true) {
                    methods._apply.call(this, score);
                    methods._target.call(this, score);
                }
            });
        }
    };

    $.fn.Andrew_Ratyli = function(method) {
        if (methods[method]) {
            return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
        } else if (typeof method === 'object' || !method) {
            return methods.init.apply(this, arguments);
        } else {
            $.error('Method ' + method + ' does not exist!');
        }
    };

    $.fn.Andrew_Ratyli.defaults = {
        cancel        : false,
        cancelHint    : 'Cancel this rating!',
        cancelOff     : '',
        cancelOn      : '',
        cancelPlace   : 'left',
        click         : undefined,
        half          : false,
        halfShow      : true,
        hints         : ['bad', 'poor', 'regular', 'good', 'gorgeous'],
        iconRange     : undefined,
        iconsize      : 24,
        mouseout      : undefined,
        mouseover     : undefined,
        noRatedMsg    : 'Not rated yet!',
        number        : 5,
        numberMax     : 20,
        path          : '',
        precision     : false,
        readOnly      : false,
        round         : { down: .25, full: .6, up: .76 },
        score         : undefined,
        scoreName     : 'score',
        single        : false,
        size          : 16,
        space         : true,
        starHalf      : '',
        starOff       : '',
        starOn        : '',
        target        : undefined,
        targetFormat  : '{score}',
        targetKeep    : false,
        targetText    : '',
        targetType    : 'hint',
        width         : undefined
    };

}(jQuery));

/*-----------------------------------------------Andrew_Progress-------------------------------------------*/
(function($){
    $.fn.extend({
        Andrew_Progress: function(options) {
            var defaults = {
                goalAmount: 100,
                currentAmount: 50,
                speed: 1000,
                ColorStyle: "",
                textBefore: '',
                textAfter: '',
                milestoneNumber: 70,
                milestoneClass: 'ak-almostfull',
                callback: function() {}
            };
            var options = $.extend(defaults, options);
            return this.each(function(){
                var obj = $(this);

                // Collect and sanitize user input
                var goalAmountParsed = parseInt(defaults.goalAmount);
                var currentAmountParsed = parseInt(defaults.currentAmount);

                // Calculate size of the Andrew_Progress bar
                var percentage = (currentAmountParsed / goalAmountParsed) * 100;

                var milestoneNumberClass = (percentage > defaults.milestoneNumber) ? ' ' + defaults.milestoneClass : ''

                // Generate the HTML
                if (defaults.textAfter) {
                    var progressBar = '<li class="ak-progressBar"><span>' + defaults.textBefore + '<em>'+currentAmountParsed+'</em>' + defaults.textAfter + '</span></li>';
                } else {
                    var progressBar = '<li class="ak-progressBar"><span>' + defaults.textBefore + '</span></li>';
                }
                var progressBarWrapped = '<ol class="bg_in h_in dis_block ovh ' + milestoneNumberClass + '">' + progressBar + '</ol>';

                // Append to the target
                obj.append(progressBarWrapped);
                // Ready
                var rendered = obj.children("ol").children("li")

                // Remove Spaces
                rendered.each(function() {
                    $(".ak-progressBar").addClass(defaults.ColorStyle);
                    $(this).html($(this).html().replace(/\s/g, ' '));
                    rendered.find('span').css({
                        "line-height": rendered.height()+"px"
                    });
                    obj.css("margin-top", (obj.parent().height() - obj.height()) / 2);
                });

                // Animate!
                rendered.animate({width: percentage +'%'}, defaults.speed, defaults.callback);

                if(typeof callback == 'function') {
                    callback.call(this)
                }
            });
        }
    });
}(jQuery));

/*-----------------------------------------------Andrew_Viewer-------------------------------------------*/
(function(i){
    function t(i) {
        return "string" == typeof i
    }
    function e(i) {
        return "number" == typeof i && !isNaN(i)
    }
    function s(i) {
        return "undefined" == typeof i
    }
    function n(i, t) {
        var s = [];
        return e(t) && s.push(t),
            s.slice.apply(i, s)
    }
    function o(i, t) {
        var e = n(arguments, 2);
        return function() {
            return i.apply(t, e.concat(n(arguments)))
        }
    }
    function a(i) {
        var t = [],
            s = i.rotate,
            n = i.scaleX,
            o = i.scaleY;
        return e(s) && t.push("rotate(" + s + "deg)"),
        e(n) && e(o) && t.push("scale(" + n + "," + o + ")"),
            t.length ? t.join(" ") : "none"
    }
    function h(i) {
        return i.offsetWidth
    }
    function r(i) {
        return t(i) ? i.replace(/^.*\//, "").replace(/[\?&#].*$/, "") : ""
    }
    function l(i, t) {
        var e;
        return i.naturalWidth ? t(i.naturalWidth, i.naturalHeight) : (e = document.createElement("img"), e.onload = function() {
            t(this.width, this.height)
        },
            void(e.src = i.src))
    }
    function d(t) {
        var e = t.length,
            s = 0,
            n = 0;
        return e && (i.each(t,
            function(i, t) {
                s += t.pageX,
                    n += t.pageY
            }), s /= e, n /= e),
            {
                pageX: s,
                pageY: n
            }
    }
    function c(i) {
        switch (i) {
            case 2:
                return x;
            case 3:
                return $;
            case 4:
                return C
        }
    }
    function u(t, e) {
        this.$element = i(t),
            this.options = i.extend({},
                u.DEFAULTS, i.isPlainObject(e) && e),
            this.isImg = !1,
            this.isBuilt = !1,
            this.isShown = !1,
            this.isViewed = !1,
            this.isFulled = !1,
            this.isPlayed = !1,
            this.wheeling = !1,
            this.playing = !1,
            this.fading = !1,
            this.tooltiping = !1,
            this.transitioning = !1,
            this.action = !1,
            this.target = !1,
            this.timeout = !1,
            this.index = 0,
            this.length = 0,
            this.init()
    }
    var m = i(window),
        v = i(document),
        f = "viewer",
        g = document.createElement(f),
        w = "fix",
        p = "scrolling",
        b = "dis_block",
        y = "dis_none_im",
        x = "ak-viewer-hide-xs-down",
        $ = "ak-viewer-hide-sm-down",
        C = "ak-viewer-hide-md-down",
        z = "ak-viewer-fade",
        F = "ak-viewer-in",
        Y = "ak-viewer-move",
        k = "ak-viewer-active bor_white border2",
        I = "ak-viewer-invisible",
        X = "ak-viewer-transition",
        P = "ak-viewer-fullscreen",
        T = "ak-viewer-fullscreen-exit",
        V = "ak-viewer-close",
        E = "img",
        S = "mousedown touchstart pointerdown MSPointerDown",
        D = "mousemove touchmove pointermove MSPointerMove",
        L = "mouseup touchend touchcancel pointerup pointercancel MSPointerUp MSPointerCancel",
        q = "wheel mousewheel DOMMouseScroll",
        R = "transitionend",
        M = "load." + f,
        W = "keydown." + f,
        _ = "click." + f,
        j = "resize." + f,
        A = "build." + f,
        B = "built." + f,
        H = "show." + f,
        U = "shown." + f,
        N = "hide." + f,
        O = "hidden." + f,
        Z = "view." + f,
        K = "viewed." + f,
        Q = "undefined" != typeof g.style.transition,
        G = Math.round,
        J = Math.sqrt,
        ii = Math.abs,
        ti = Math.min,
        ei = Math.max,
        si = Number;
    u.prototype = {
        constructor: u,
        init: function() {
            var t = this.options,
                e = this.$element,
                s = e.is(E),
                n = s ? e: e.find(E),
                o = n.length,
                a = i.proxy(this.ready, this);
            o && (i.isFunction(t.build) && e.one(A, t.build), this.trigger(A).isDefaultPrevented() || (Q || (t.transition = !1), this.isImg = s, this.length = o, this.count = 0, this.$images = n, this.$body = i("main"), t.inline ? (e.one(B, i.proxy(function() {
                    this.view()
                },
                this)), n.each(function() {
                this.complete ? a() : i(this).one(M, a)
            })) : e.on(_, i.proxy(this.start, this))))
        },
        ready: function() {
            this.count++,
            this.count === this.length && this.build()
        },
        build: function() {
            var t, e, s, n, o, a, h = this.options,
                r = this.$element;
            this.isBuilt || (
                this.$parent = t = r.parent(),
                    this.$viewer = e = i(u.TEMPLATE),
                    this.$canvas = e.find(".ak-viewer-canvas"),
                    this.$footer = e.find(".ak-viewer-footer"),
                    this.$title = s = e.find(".ak-viewer-title"),
                    this.$toolbar = n = e.find(".ak-viewer-toolbar"),
                    this.$navbar = o = e.find(".ak-viewer-navbar"),
                    this.$button = a = e.find(".ak-viewer-button"),
                    this.$tooltip = e.find(".ak-viewer-tooltip"),
                    this.$player = e.find(".ak-viewer-player"),
                    this.$list = e.find(".ak-viewer-list"),
                    s.addClass(h.title ? c(h.title) : y),
                    n.addClass(h.toolbar ? c(h.toolbar) : y),
                    n.find("li[class*=zoom]").toggleClass(I, !h.zoomable),
                    n.find("li[class*=flip]").toggleClass(I, !h.scalable),
                h.rotatable || n.find("li[class*=rotate]").addClass(I).appendTo(n),
                    o.addClass(h.navbar ? c(h.navbar) : y),
                    h.inline ? (a.addClass(P),
                        e.css("z-index", h.zIndexInline),
                    "static" === t.css("position") && t.css("position", "relative")) : (a.addClass(V),
                        e.css("z-index", h.zIndex).addClass([w, z, y].join(" "))),
                    i("body").append(e),
                h.inline && (this.render(),
                    this.bind(),
                    this.isShown = !0),
                    this.isBuilt = !0,
                i.isFunction(h.built) && r.one(B, h.built),
                    this.trigger(B)
            )
        },
        unbuild: function() {
            var i = this.options,
                t = this.$element;
            this.isBuilt && (i.inline && t.removeClass(y), this.$viewer.remove())
        },
        bind: function() {
            var t = this.options,
                e = this.$element;
            i.isFunction(t.view) && e.on(Z, t.view),
            i.isFunction(t.viewed) && e.on(K, t.viewed),
                this.$viewer.on(_, i.proxy(this.click, this)).on(q, i.proxy(this.wheel, this)),
                this.$canvas.on(S, i.proxy(this.mousedown, this)),
                v.on(D, this._mousemove = o(this.mousemove, this)).on(L, this._mouseup = o(this.mouseup, this)).on(W, this._keydown = o(this.keydown, this)),
                m.on(j, this._resize = o(this.resize, this))
        },
        unbind: function() {
            var t = this.options,
                e = this.$element;
            i.isFunction(t.view) && e.off(Z, t.view),
            i.isFunction(t.viewed) && e.off(K, t.viewed),
                this.$viewer.off(_, this.click).off(q, this.wheel),
                this.$canvas.off(S, this.mousedown),
                v.off(D, this._mousemove).off(L, this._mouseup).off(W, this._keydown),
                m.off(j, this._resize)
        },
        render: function() {
            this.initContainer(),
                this.initViewer(),
                this.initList(),
                this.renderViewer()
        },
        initContainer: function() {
            this.container = {
                width: m.innerWidth(),
                height: m.innerHeight()
            }
        },
        initViewer: function() {
            var t, e = this.options,
                s = this.$parent;
            e.inline && (this.parent = t = {
                width: ei(s.width(), e.minWidth),
                height: ei(s.height(), e.minHeight)
            }),
            (this.isFulled || !t) && (t = this.container),
                this.viewer = i.extend({},
                    t)
        },
        renderViewer: function() {
            this.options.inline && !this.isFulled && this.$viewer.css(this.viewer)
        },
        initList: function() {
            var e = this.options,
                s = this.$element,
                n = this.$list,
                o = [];
            this.$images.each(function(s) {
                var n = this.src,
                    a = this.alt || r(n),
                    h = e.url;
                n && (t(h) ? h = this.getAttribute(h) : i.isFunction(h) && (h = h.call(this, this)), o.push('<li><img src="' + n + '" data-action="view" data-index="' + s + '" data-original-url="' + (h || n) + '" alt="' + a + '" /></li>'))
            }),
                n.html(o.join("")).find(E).one(M, {
                        filled: !0
                    },
                    i.proxy(this.loadImage, this)),
                this.$items = n.children(),
            e.transition && s.one(K,
                function() {
                    n.addClass(X)
                })
        },
        renderList: function(i) {
            var t = i || this.index,
                e = this.$items.eq(t).outerWidth(),
                s = e + 1;
            this.$list.css({
                /*width: 2 * this.length,*/
                marginLeft: (this.viewer.width - e) / 2 - s * t
            })
        },
        resetList: function() {
            this.$list.empty().removeClass(X).css("margin-left", 0)
        },
        initImage: function(t) {
            var e = this.options,
                s = this.$image,
                n = this.viewer,
                o = this.$footer.height(),
                a = n.width,
                h = ei(n.height - o, o),
                r = this.image || {};
            l(s[0], i.proxy(function(s, n) {
                    var o, l, d = s / n,
                        c = a,
                        u = h;
                    h * d > a ? u = a / d: c = h * d,
                        c = ti(.9 * c, s),
                        u = ti(.9 * u, n),
                        l = {
                            naturalWidth: s,
                            naturalHeight: n,
                            aspectRatio: d,
                            ratio: c / s,
                            width: c,
                            height: u,
                            left: (a - c) / 2,
                            top: (h - u) / 2
                        },
                        o = i.extend({},
                            l),
                    e.rotatable && (l.rotate = r.rotate || 0, o.rotate = 0),
                    e.scalable && (l.scaleX = r.scaleX || 1, l.scaleY = r.scaleY || 1, o.scaleX = 1, o.scaleY = 1),
                        this.image = l,
                        this.initialImage = o,
                    i.isFunction(t) && t()
                },
                this))
        },
        renderImage: function(t) {
            var e = this.image,
                s = this.$image;
            s.css({
                width: e.width,
                height: e.height,
                marginLeft: e.left,
                marginTop: e.top,
                transform: a(e)
            }),
            i.isFunction(t) && (this.transitioning ? s.one(R, t) : t())
        },
        resetImage: function() {
            this.$image.remove(),
                this.$image = null
        },
        start: function(t) {
            var e = t.target;
            i(e).is("img") && (this.target = e, this.show())
        },
        click: function(t) {
            var e = i(t.target),
                s = e.data("action"),
                n = this.image;
            switch (s) {
                case "mix":
                    this.isPlayed ? this.stop() : this.options.inline ? this.isFulled ? this.exit() : this.full() : this.hide();
                    break;
                case "view":
                    this.view(e.data("index"));
                    break;
                case "zoom-in":
                    this.zoom(.1, !0);
                    break;
                case "zoom-out":
                    this.zoom( - .1, !0);
                    break;
                case "one-to-one":
                    this.toggle();
                    break;
                case "reset":
                    this.reset();
                    break;
                case "prev":
                    this.prev();
                    break;
                case "play":
                    this.play();
                    break;
                case "next":
                    this.next();
                    break;
                case "rotate-left":
                    this.rotate( - 90);
                    break;
                case "rotate-right":
                    this.rotate(90);
                    break;
                case "flip-horizontal":
                    this.scaleX( - n.scaleX || -1);
                    break;
                case "flip-vertical":
                    this.scaleY( - n.scaleY || -1);
                    break;
                default:
                    this.isPlayed && this.stop()
            }
        },
        load: function() {
            var t = this.options,
                e = this.viewer,
                s = this.$image;
            this.timeout && (clearTimeout(this.timeout), this.timeout = !1),
                s.removeClass(I).css("cssText", "width:0;height:0;margin-left:" + e.width / 2 + "px;margin-top:" + e.height / 2 + "px;max-width:none!important;visibility:visible;"),
                this.initImage(i.proxy(function() {
                        s.toggleClass(X, t.transition).toggleClass(Y, t.movable),
                            this.renderImage(i.proxy(function() {
                                    this.isViewed = !0,
                                        this.trigger(K)
                                },
                                this))
                    },
                    this))
        },
        loadImage: function(t) {
            var e = t.target,
                s = i(e),
                n = s.parent(),
                o = n.width(),
                a = n.height(),
                h = t.data && t.data.filled;
            l(e,
                function(i, t) {
                    var e = i / t,
                        n = o,
                        r = a;
                    a * e > o ? h ? n = a * e: r = o / e: h ? r = o / e: n = a * e,
                        s.css({
                            width: n,
                            height: r,
                            marginLeft: (o - n) / 2,
                            marginTop: (a - r) / 2
                        })
                })
        },
        resize: function() {
            this.initContainer(),
                this.initViewer(),
                this.renderViewer(),
                this.renderList(),
                this.initImage(i.proxy(function() {
                        this.renderImage()
                    },
                    this)),
            this.isPlayed && this.$player.find(E).one(M, i.proxy(this.loadImage, this)).trigger(M)
        },
        wheel: function(t) {
            var e = t.originalEvent || t,
                s = si(this.options.zoomRatio) || .1,
                n = 1;
            this.isViewed && (t.preventDefault(), this.wheeling || (this.wheeling = !0, setTimeout(i.proxy(function() {
                    this.wheeling = !1
                },
                this), 50), e.deltaY ? n = e.deltaY > 0 ? 1 : -1 : e.wheelDelta ? n = -e.wheelDelta / 120 : e.detail && (n = e.detail > 0 ? 1 : -1), this.zoom( - n * s, !0, t)))
        },
        keydown: function(i) {
            var t = this.options,
                e = i.which;
            if (this.isFulled && t.keyboard) switch (e) {
                case 27:
                    this.isPlayed ? this.stop() : t.inline ? this.isFulled && this.exit() : this.hide();
                    break;
                case 32:
                    this.isPlayed && this.stop();
                    break;
                case 37:
                    this.prev();
                    break;
                case 38:
                    i.preventDefault(),
                        this.zoom(t.zoomRatio, !0);
                    break;
                case 39:
                    this.next();
                    break;
                case 40:
                    i.preventDefault(),
                        this.zoom( - t.zoomRatio, !0);
                    break;
                case 48:
                case 49:
                    (i.ctrlKey || i.shiftKey) && (i.preventDefault(), this.toggle())
            }
        },
        mousedown: function(i) {
            var t, e = this.options,
                s = i.originalEvent,
                n = s && s.touches,
                o = i,
                a = e.movable ? "move": !1;
            if (this.isViewed) {
                if (n) {
                    if (t = n.length, t > 1) {
                        if (!e.zoomable || 2 !== t) return;
                        o = n[1],
                            this.startX2 = o.pageX,
                            this.startY2 = o.pageY,
                            a = "zoom"
                    } else this.isSwitchable() && (a = "switch");
                    o = n[0]
                }
                a && (i.preventDefault(), this.action = a, this.startX = o.pageX || s && s.pageX, this.startY = o.pageY || s && s.pageY)
            }
        },
        mousemove: function(i) {
            var t, e = this.options,
                s = this.action,
                n = this.$image,
                o = i.originalEvent,
                a = o && o.touches,
                h = i;
            if (this.isViewed) {
                if (a) {
                    if (t = a.length, t > 1) {
                        if (!e.zoomable || 2 !== t) return;
                        h = a[1],
                            this.endX2 = h.pageX,
                            this.endY2 = h.pageY
                    }
                    h = a[0]
                }
                s && (i.preventDefault(), "move" === s && e.transition && n.hasClass(X) && n.removeClass(X), this.endX = h.pageX || o && o.pageX, this.endY = h.pageY || o && o.pageY, this.change(i))
            }
        },
        mouseup: function(i) {
            var t = this.action;
            t && (i.preventDefault(), "move" === t && this.options.transition && this.$image.addClass(X), this.action = !1)
        },
        show: function() {
            var t, e = this.options;
            e.inline || this.transitioning || (this.isBuilt || this.build(), i.isFunction(e.show) && this.$element.one(H, e.show), this.trigger(H).isDefaultPrevented() || (this.$body.removeClass(p), t = this.$viewer.removeClass(y), this.$element.one(U, i.proxy(function() {
                    this.view(this.target ? this.$images.index(this.target) : this.index),
                        this.target = !1
                },
                this)), e.transition ? (this.transitioning = !0, t.addClass(X), h(t[0]), t.one(R, i.proxy(this.shown, this)).addClass(F)) : (t.addClass(F), this.shown())))
        },
        hide: function() {
            var t = this.options,
                e = this.$viewer;
            t.inline || this.transitioning || !this.isShown || (i.isFunction(t.hide) && this.$element.one(N, t.hide), this.trigger(N).isDefaultPrevented() || (this.isViewed && t.transition ? (this.transitioning = !0, this.$image.one(R, i.proxy(function() {
                    e.one(R, i.proxy(this.hidden, this)).removeClass(F)
                },
                this)), this.zoomTo(0, !1, !1, !0)) : (e.removeClass(F), this.hidden())))
        },
        view: function(t) {
            var e, s, n, o, a, h = this.$title;
            t = Number(t) || 0,
            !this.isShown || this.isPlayed || 0 > t || t >= this.length || this.isViewed && t === this.index || this.trigger(Z).isDefaultPrevented() || (s = this.$items.eq(t), n = s.find(E), o = n.data("originalUrl"), a = n.attr("alt"), this.$image = e = i('<img src="' + o + '" alt="' + a + '">'), this.isViewed && this.$items.eq(this.index).removeClass(k), s.addClass(k), this.isViewed = !1, this.index = t, this.image = null, this.$canvas.html(e.addClass(I)), this.renderList(), h.empty(), this.$element.one(K, i.proxy(function() {
                    var i = this.image,
                        t = i.naturalWidth,
                        e = i.naturalHeight;
                    h.html(a + " (" + t + " &times; " + e + ")")
                },
                this)), e[0].complete ? this.load() : (e.one(M, i.proxy(this.load, this)), this.timeout && clearTimeout(this.timeout), this.timeout = setTimeout(i.proxy(function() {
                    e.removeClass(I),
                        this.timeout = !1
                },
                this), 1e3)))
        },
        prev: function() {
            this.view(ei(this.index - 1, 0))
        },
        next: function() {
            this.view(ti(this.index + 1, this.length - 1))
        },
        move: function(i, t) {
            var e = this.image;
            this.moveTo(s(i) ? i: e.left + si(i), s(t) ? t: e.top + si(t))
        },
        moveTo: function(i, t) {
            var n = this.image,
                o = !1;
            s(t) && (t = i),
                i = si(i),
                t = si(t),
            this.isViewed && !this.isPlayed && this.options.movable && (e(i) && (n.left = i, o = !0), e(t) && (n.top = t, o = !0), o && this.renderImage())
        },
        zoom: function(i, t, e) {
            var s = this.image;
            i = si(i),
                i = 0 > i ? 1 / (1 - i) : 1 + i,
                this.zoomTo(s.width * i / s.naturalWidth, t, e)
        },
        zoomTo: function(i, t, s, n) {
            var o, a, h, r, l, c = this.options,
                u = .01,
                m = 100,
                v = this.image,
                f = v.width,
                g = v.height;
            i = ei(0, i),
            e(i) && this.isViewed && !this.isPlayed && (n || c.zoomable) && (n || (u = ei(u, c.minZoomRatio), m = ti(m, c.maxZoomRatio), i = ti(ei(i, u), m)), i > .95 && 1.05 > i && (i = 1), a = v.naturalWidth * i, h = v.naturalHeight * i, s && (o = s.originalEvent) ? (r = this.$viewer.offset(), l = o.touches ? d(o.touches) : {
                pageX: s.pageX || o.pageX || 0,
                pageY: s.pageY || o.pageY || 0
            },
                v.left -= (a - f) * ((l.pageX - r.left - v.left) / f), v.top -= (h - g) * ((l.pageY - r.top - v.top) / g)) : (v.left -= (a - f) / 2, v.top -= (h - g) / 2), v.width = a, v.height = h, v.ratio = i, this.renderImage(), t && this.tooltip())
        },
        rotate: function(i) {
            this.rotateTo((this.image.rotate || 0) + si(i))
        },
        rotateTo: function(i) {
            var t = this.image;
            i = si(i),
            e(i) && this.isViewed && !this.isPlayed && this.options.rotatable && (t.rotate = i, this.renderImage())
        },
        scale: function(i, t) {
            var n = this.image,
                o = !1;
            s(t) && (t = i),
                i = si(i),
                t = si(t),
            this.isViewed && !this.isPlayed && this.options.scalable && (e(i) && (n.scaleX = i, o = !0), e(t) && (n.scaleY = t, o = !0), o && this.renderImage())
        },
        scaleX: function(i) {
            this.scale(i, this.image.scaleY)
        },
        scaleY: function(i) {
            this.scale(this.image.scaleX, i)
        },
        play: function() {
            var t, s = this.options,
                n = this.$player,
                o = i.proxy(this.loadImage, this),
                a = [],
                h = 0,
                r = 0;
            this.isShown && !this.isPlayed && (s.fullscreen && this.requestFullscreen(), this.isPlayed = !0, n.addClass(b), this.$items.each(function(t) {
                var e = i(this),
                    l = e.find(E),
                    d = i('<img src="' + l.data("originalUrl") + '" alt="' + l.attr("alt") + '">');
                h++,
                    d.addClass(z).toggleClass(X, s.transition),
                e.hasClass(k) && (d.addClass(F), r = t),
                    a.push(d),
                    d.one(M, {
                            filled: !1
                        },
                        o),
                    n.append(d)
            }), e(s.interval) && s.interval > 0 && (t = i.proxy(function() {
                    this.playing = setTimeout(function() {
                            a[r].removeClass(F),
                                r++,
                                r = h > r ? r: 0,
                                a[r].addClass(F),
                                t()
                        },
                        s.interval)
                },
                this), h > 1 && t()))
        },
        stop: function() {
            this.isPlayed && (this.options.fullscreen && this.exitFullscreen(), this.isPlayed = !1, clearTimeout(this.playing), this.$player.removeClass(b).empty())
        },
        full: function() {
            var t = this.options,
                e = this.$image,
                s = this.$list;
            this.isShown && !this.isPlayed && !this.isFulled && t.inline && (this.isFulled = !0, this.$body.removeClass(p), this.$button.addClass(T), t.transition && (e.removeClass(X), s.removeClass(X)), this.$viewer.addClass(w).removeAttr("style").css("z-index", t.zIndex), this.initContainer(), this.viewer = i.extend({},
                this.container), this.renderList(), this.initImage(i.proxy(function() {
                    this.renderImage(function() {
                        t.transition && setTimeout(function() {
                                e.addClass(X),
                                    s.addClass(X)
                            },
                            0)
                    })
                },
                this)))
        },
        exit: function() {
            var t = this.options,
                e = this.$image,
                s = this.$list;
            this.isFulled && (this.isFulled = !1, this.$body.removeClass(p), this.$button.removeClass(T), t.transition && (e.removeClass(X), s.removeClass(X)), this.$viewer.removeClass(w).css("z-index", t.zIndexInline), this.viewer = i.extend({},
                this.parent), this.renderViewer(), this.renderList(), this.initImage(i.proxy(function() {
                    this.renderImage(function() {
                        t.transition && setTimeout(function() {
                                e.addClass(X),
                                    s.addClass(X)
                            },
                            0)
                    })
                },
                this)))
        },
        tooltip: function() {
            var t = this.options,
                e = this.$tooltip,
                s = this.image,
                n = [b, z, X].join(" ");
            this.isViewed && !this.isPlayed && t.tooltip && (e.text(G(100 * s.ratio) + "%"), this.tooltiping ? clearTimeout(this.tooltiping) : t.transition ? (this.fading && e.trigger(R), e.addClass(n), h(e[0]), e.addClass(F)) : e.addClass(b), this.tooltiping = setTimeout(i.proxy(function() {
                    t.transition ? (e.one(R, i.proxy(function() {
                            e.removeClass(n),
                                this.fading = !1
                        },
                        this)).removeClass(F), this.fading = !0) : e.removeClass(b),
                        this.tooltiping = !1
                },
                this), 1e3))
        },
        toggle: function() {
            1 === this.image.ratio ? this.zoomTo(this.initialImage.ratio, !0) : this.zoomTo(1, !0)
        },
        reset: function() {
            this.isViewed && !this.isPlayed && (this.image = i.extend({},
                this.initialImage), this.renderImage())
        },
        update: function() {
            var t, e = this.$element,
                s = this.$images,
                n = [];
            if (this.isImg) {
                if (!e.parent().length) return this.destroy()
            } else this.$images = s = e.find(E),
                this.length = s.length;
            this.isBuilt && (i.each(this.$items,
                function(t) {
                    var e = i(this).find("img")[0],
                        o = s[t];
                    o ? o.src !== e.src && n.push(t) : n.push(t)
                }), this.$list.width("auto"), this.initList(), this.isShown && (this.length ? this.isViewed && (t = i.inArray(this.index, n), t >= 0 ? (this.isViewed = !1, this.view(ei(this.index - (t + 1), 0))) : this.$items.eq(this.index).addClass(k)) : (this.$image = null, this.isViewed = !1, this.index = 0, this.image = null, this.$canvas.empty(), this.$title.empty())))
        },
        destroy: function() {
            var i = this.$element;
            this.options.inline ? this.unbind() : (this.isShown && this.unbind(), i.off(_, this.start)),
                this.unbuild(),
                i.removeData(f)
        },
        trigger: function(t, e) {
            var s = i.Event(t, e);
            return this.$element.trigger(s),
                s
        },
        shown: function() {
            var t = this.options;
            this.transitioning = !1,
                this.isFulled = !0,
                this.isShown = !0,
                this.isVisible = !0,
                this.render(),
                this.bind(),
            i.isFunction(t.shown) && this.$element.one(U, t.shown),
                this.trigger(U)
        },
        hidden: function() {
            var t = this.options;
            this.transitioning = !1,
                this.isViewed = !1,
                this.isFulled = !1,
                this.isShown = !1,
                this.isVisible = !1,
                this.unbind(),
                this.$body.addClass(p),
                this.$viewer.addClass(y),
                this.resetList(),
                this.resetImage(),
            i.isFunction(t.hidden) && this.$element.one(O, t.hidden),
                this.trigger(O)
        },
        requestFullscreen: function() {
            var i = document.documentElement; ! this.isFulled || document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement || (i.requestFullscreen ? i.requestFullscreen() : i.msRequestFullscreen ? i.msRequestFullscreen() : i.mozRequestFullScreen ? i.mozRequestFullScreen() : i.webkitRequestFullscreen && i.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT))
        },
        exitFullscreen: function() {
            this.isFulled && (document.exitFullscreen ? document.exitFullscreen() : document.msExitFullscreen ? document.msExitFullscreen() : document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.webkitExitFullscreen && document.webkitExitFullscreen())
        },
        change: function(i) {
            var t = this.endX - this.startX,
                e = this.endY - this.startY;
            switch (this.action) {
                case "move":
                    this.move(t, e);
                    break;
                case "zoom":
                    this.zoom(function(i, t, e, s) {
                        var n = J(i * i + t * t),
                            o = J(e * e + s * s);
                        return (o - n) / n
                    } (ii(this.startX - this.startX2), ii(this.startY - this.startY2), ii(this.endX - this.endX2), ii(this.endY - this.endY2)), !1, i),
                        this.startX2 = this.endX2,
                        this.startY2 = this.endY2;
                    break;
                case "switch":
                    this.action = "switched",
                    ii(t) > ii(e) && (t > 1 ? this.prev() : -1 > t && this.next())
            }
            this.startX = this.endX,
                this.startY = this.endY
        },
        isSwitchable: function() {
            var i = this.image,
                t = this.viewer;
            return i.left >= 0 && i.top >= 0 && i.width <= t.width && i.height <= t.height
        }
    },
        u.DEFAULTS = {
            inline: !1,
            button: !0,
            navbar: !0,
            title: !0,
            toolbar: !0,
            tooltip: !0,
            movable: !0,
            zoomable: !0,
            rotatable: !0,
            scalable: !0,
            transition: !0,
            fullscreen: !0,
            keyboard: !0,
            interval: 5e3,
            minWidth: 200,
            minHeight: 100,
            zoomRatio: .1,
            minZoomRatio: .01,
            maxZoomRatio: 100,
            zIndex: 9999,
            zIndexInline: 0,
            url: "src",
            build: null,
            built: null,
            show: null,
            shown: null,
            hide: null,
            hidden: null,
            view: null,
            viewed: null
        },
        u.TEMPLATE = '<div class="ak-viewer-container">' +
            '<div class="ak-viewer-canvas"></div>' +
            '<div class="ak-viewer-footer animated slideInUp h_19_em bg_black07">' +
            '<div class="ak-viewer-title"></div>' +
            '<ul class="ak-viewer-toolbar">' +
            '<li class="ak-viewer-one-to-one bg_black07" data-action="one-to-one"></li>' +
            '<li class="ak-viewer-zoom-in bg_black07" data-action="zoom-in"></li>' +
            '<li class="ak-viewer-zoom-out bg_black07" data-action="zoom-out"></li>' +
            '<li class="ak-viewer-prev bg_black07" data-action="prev"></li>' +
            '<li class="ak-viewer-next bg_black07" data-action="next"></li>' +
            '<li class="ak-viewer-rotate-left bg_black07" data-action="rotate-left"></li>' +
            '<li class="ak-viewer-rotate-right bg_black07" data-action="rotate-right"></li>' +
            '<li class="ak-viewer-flip-horizontal bg_black07" data-action="flip-horizontal"></li>' +
            '<li class="ak-viewer-flip-vertical bg_black07" data-action="flip-vertical"></li>' +
            '<li class="ak-viewer-reset bg_black07" data-action="reset"></li>' +
            '</ul>' +
            '<div class="ak-viewer-navbar bg_black04">' +
            '<ul class="ak-viewer-list"></ul>' +
            '</div>' +
            '</div>' +
            '<div class="ak-viewer-tooltip"></div>' +
            '<button class="ak-viewer-button bg_black07" data-action="mix"></button>' +
            '<div class="ak-mask"></div>' +
            '</div>',
        u.other = i.fn.Andrew_Viewer,
        i.fn.Andrew_Viewer = function(e) {
            var o, a = n(arguments, 1);
            return this.each(function() {
                var s, n = i(this),
                    h = n.data(f);
                if (!h) {
                    if (/destroy|hide|exit|stop|reset/.test(e)) return;
                    n.data(f, h = new u(this, e))
                }
                t(e) && i.isFunction(s = h[e]) && (o = s.apply(h, a))
            }),
                s(o) ? this: o
        },
        i.fn.Andrew_Viewer.Constructor = u,
        i.fn.Andrew_Viewer.setDefaults = u.setDefaults,
        i.fn.Andrew_Viewer.noConflict = function() {
            return i.fn.Andrew_Viewer = u.other,
                this
        }
}(jQuery));

/*-----------------------------------------------Andrew_Lazyload-------------------------------------------*/
(function($){
    var $window = $(window);
    $.fn.Andrew_Lazyload = function(options) {
        var elements = this;
        var $container;
        var settings = {
            threshold       : 0,
            failure_limit   : 0,
            event           : "scroll",
            effect          : "show",
            container       : window,
            data_attribute  : "original",
            skip_invisible  : true,
            appear          : null,
            load            : null,
            placeholder     : ""
        };

        function update() {
            var counter = 0;

            elements.each(function() {
                var $this = $(this);
                if (settings.skip_invisible && !$this.is(":visible")) {
                    return;
                }
                if ($.abovethetop(this, settings) ||
                    $.leftofbegin(this, settings)) {
                    /* Nothing. */
                } else if (!$.belowthefold(this, settings) &&
                    !$.rightoffold(this, settings)) {
                    $this.trigger("appear");
                    /* if we found an image we'll load, reset the counter */
                    counter = 0;
                } else {
                    if (++counter > settings.failure_limit) {
                        return false;
                    }
                }
            });

        }

        if(options) {
            /* Maintain BC for a couple of versions. */
            if (undefined !== options.failurelimit) {
                options.failure_limit = options.failurelimit;
                delete options.failurelimit;
            }
            if (undefined !== options.effectspeed) {
                options.effect_speed = options.effectspeed;
                delete options.effectspeed;
            }

            $.extend(settings, options);
        }

        /* Cache container as jQuery as object. */
        $container = (settings.container === undefined ||
            settings.container === window) ? $window : $(settings.container);

        /* Fire one scroll event per scroll. Not one scroll event per image. */
        if (0 === settings.event.indexOf("scroll")) {
            $container.bind(settings.event, function() {
                return update();
            });
        }

        this.each(function() {
            var self = this;
            var $self = $(self);

            self.loaded = false;

            /* If no src attribute given use data:uri. */
            if ($self.attr("src") === undefined || $self.attr("src") === false) {
                if ($self.is("img")) {
                    $self.attr("src", settings.placeholder);
                }
            }

            /* When appear is triggered load original image. */
            $self.one("appear", function() {
                if (!this.loaded) {
                    if (settings.appear) {
                        var elements_left = elements.length;
                        settings.appear.call(self, elements_left, settings);
                    }
                    $("<img />")
                        .bind("load", function() {

                            var original = $self.attr("data-" + settings.data_attribute);
                            $self.hide();
                            if ($self.is("img")) {
                                $self.attr("src", original);
                            } else {
                                $self.css("background-image", "url('" + original + "')");
                            }
                            $self[settings.effect](settings.effect_speed);

                            self.loaded = true;

                            /* Remove image from array so it is not looped next time. */
                            var temp = $.grep(elements, function(element) {
                                return !element.loaded;
                            });
                            elements = $(temp);

                            if (settings.load) {
                                var elements_left = elements.length;
                                settings.load.call(self, elements_left, settings);
                            }
                        })
                        .attr("src", $self.attr("data-" + settings.data_attribute));
                }
            });

            /* When wanted event is triggered load original image */
            /* by triggering appear.                              */
            if (0 !== settings.event.indexOf("scroll")) {
                $self.bind(settings.event, function() {
                    if (!self.loaded) {
                        $self.trigger("appear");
                    }
                });
            }
        });

        /* Check if something appears when window is resized. */
        $window.bind("resize", function() {
            update();
        });

        /* With IOS5 force loading images when navigating with back button. */
        /* Non optimal workaround. */
        if ((/(?:iphone|ipod|ipad).*os 5/gi).test(navigator.appVersion)) {
            $window.bind("pageshow", function(event) {
                if (event.originalEvent && event.originalEvent.persisted) {
                    elements.each(function() {
                        $(this).trigger("appear");
                    });
                }
            });
        }

        /* Force initial check if images should appear. */
        $(document).ready(function() {
            update();
        });

        return this;
    };

    /* Convenience methods in jQuery namespace.           */
    /* Use as  $.belowthefold(element, {threshold : 100, container : window}) */

    $.belowthefold = function(element, settings) {
        var fold;

        if (settings.container === undefined || settings.container === window) {
            fold = (window.innerHeight ? window.innerHeight : $window.height()) + $window.scrollTop();
        } else {
            fold = $(settings.container).offset().top + $(settings.container).height();
        }

        return fold <= $(element).offset().top - settings.threshold;
    };

    $.rightoffold = function(element, settings) {
        var fold;

        if (settings.container === undefined || settings.container === window) {
            fold = $window.width() + $window.scrollLeft();
        } else {
            fold = $(settings.container).offset().left + $(settings.container).width();
        }

        return fold <= $(element).offset().left - settings.threshold;
    };

    $.abovethetop = function(element, settings) {
        var fold;

        if (settings.container === undefined || settings.container === window) {
            fold = $window.scrollTop();
        } else {
            fold = $(settings.container).offset().top;
        }

        return fold >= $(element).offset().top + settings.threshold  + $(element).height();
    };

    $.leftofbegin = function(element, settings) {
        var fold;

        if (settings.container === undefined || settings.container === window) {
            fold = $window.scrollLeft();
        } else {
            fold = $(settings.container).offset().left;
        }

        return fold >= $(element).offset().left + settings.threshold + $(element).width();
    };

    $.inviewport = function(element, settings) {
        return !$.rightoffold(element, settings) && !$.leftofbegin(element, settings) &&
            !$.belowthefold(element, settings) && !$.abovethetop(element, settings);
    };

    /* Custom selectors for your convenience.   */
    /* Use as $("img:below-the-fold").something() or */
    /* $("img").filter(":below-the-fold").something() which is faster */

    $.extend($.expr[":"], {
        "below-the-fold" : function(a) { return $.belowthefold(a, {threshold : 0}); },
        "above-the-top"  : function(a) { return !$.belowthefold(a, {threshold : 0}); },
        "right-of-screen": function(a) { return $.rightoffold(a, {threshold : 0}); },
        "left-of-screen" : function(a) { return !$.rightoffold(a, {threshold : 0}); },
        "in-viewport"    : function(a) { return $.inviewport(a, {threshold : 0}); },
        /* Maintain BC for couple of versions. */
        "above-the-fold" : function(a) { return !$.belowthefold(a, {threshold : 0}); },
        "right-of-fold"  : function(a) { return $.rightoffold(a, {threshold : 0}); },
        "left-of-fold"   : function(a) { return !$.rightoffold(a, {threshold : 0}); }
    });

}(jQuery));

/*-----------------------------------------------Andrew_ZoomImage-------------------------------------------*/
(function($){
    var defaults = {
        fadeduration:200
    };
    var $ak_zoomimage
    var currentzoominfo = {
        $zoomimage:null,
        offset:[,],
        settings:null,
        multiplier:[,]
    };
    function getDimensions($target){
        return {
            w:$target.width(),
            h:$target.height()
        }
    }
    function getoffset(what, offsettype){ // custom get element offset from document (since jQuery version is whack in mobile browsers
        return (what.offsetParent)? what[offsettype]+getoffset(what.offsetParent, offsettype) : what[offsettype]
    }

    function Andrew_ZoomImage($img, settings){ // Andrew_ZoomImage plugin function
        var s = settings || defaults;
        var trigger = 'mouseenter';
        $img.off('mouseenter').on(trigger, function(e){ // on 'touchstart' or 'mouseenter'
            var jqueryevt = e; // remember jQuery event object (for use to call e.stopPropagation())
            var e = jqueryevt.originalEvent.changedTouches? jqueryevt.originalEvent.changedTouches[0] : jqueryevt;
            var offset = {left:getoffset($img.get(0), 'offsetLeft'), top:getoffset($img.get(0), 'offsetTop') };
            var mousecoord = [e.pageX - offset.left, e.pageY - offset.top];
            var $zoomimage;
            var zoomdfd = $.Deferred();
            var imgdimensions = {imgw:null, imgh:null, zoomimgw:null, zoomimgh:null};
            $ak_zoomimage.html( '<img src="' + $img.attr('src') + '" />' ); // add image inside zoom container
            $zoomimage = $ak_zoomimage.find('img');
            if ($zoomimage.get(0).complete){
                zoomdfd.resolve()
            }
            else{
                $zoomimage.on('load', function(){
                    zoomdfd.resolve()
                })
            }
            zoomdfd.done(function(){
                var imgdimensions = getDimensions($img);
                $ak_zoomimage.css({width:$img.parent().outerWidth(), height:$img.parent().outerHeight(), left:$img.parent().offset().left, top:$img.parent().offset().top}); // set zoom container dimensions and position
                var ak_ZoomImage_containerdimensions = getDimensions($ak_zoomimage);
                var zoomimgdimensions = getDimensions($zoomimage);
                $ak_zoomimage.stop().css({visibility:'visible', opacity:0}).animate({opacity:1}, s.fadeduration); // fade zoom container into view
                currentzoominfo = {$zoomimage:$zoomimage, offset:offset, settings:s, multiplier:[zoomimgdimensions.w/ak_ZoomImage_containerdimensions.w, zoomimgdimensions.h/ak_ZoomImage_containerdimensions.h]}
            });
            jqueryevt.stopPropagation() // stopPropagation() works on jquery evt object (versus jqueryevt.originalEvent.changedTouches[0]
        })
    }
    $.fn.Andrew_ZoomImage = function(options){ // set up jquery Andrew_ZoomImage plugin
        var s = $.extend({}, defaults, options);

        return this.each(function(){ //return jQuery obj
            var $target = $(this);
            $target = ($target.is('img'))? $target : $target.find('img:eq(0)');
            if ($target.length == 0){
                return true
            }
            Andrew_ZoomImage($target, s)
        }) // end return this.each
    };
    $(function(){ // on DOM load
        $ak_zoomimage = $('<div class="ak-ZoomImage border2 bor_title" />').appendTo(document.body)
        $ak_zoomimage.on('mousemove', function(e){
            var $zoomimage = currentzoominfo.$zoomimage;
            var imgoffset = currentzoominfo.offset;
            var mousecoord = [e.pageX-imgoffset.left, e.pageY-imgoffset.top];
            var multiplier = currentzoominfo.multiplier;
            $zoomimage.css({left: -mousecoord[0] * multiplier[0] + mousecoord[0] , top: -mousecoord[1] * multiplier[1] + mousecoord[1]})
        });
        $ak_zoomimage.on('mouseleave', function(){
            $ak_zoomimage.stop().animate({opacity:0}, currentzoominfo.settings.fadeduration, function(){
                $(this).css({visibility:'hidden'})
            });
        })
    })
}(jQuery));

/*-----------------------------------------------Andrew_HoverBorder-------------------------------------------*/
(function($){
    $.fn.Andrew_HoverBorder = function(setting) {
        var option = $.extend({
                start_delay: 300,
                end_delay: 100,
                border: "1px"
            },
            setting);
        var hborder = $(this);
        hborder.hover(function () {
            var obj = $(this);
            $(obj).find('.top_0.left_0').stop(true).animate({
                height: $(obj).innerHeight()
            },option.start_delay);
            $(obj).find('.bottom_0.left_0').stop(true).delay(option.start_delay).animate({
                width: $(obj).innerWidth()
            },option.start_delay);
            $(obj).find('.bottom_0.right_0').stop(true).animate({
                height: $(obj).innerHeight()
            },option.start_delay);
            $(obj).find('.top_0.right_0').stop(true).delay(option.start_delay).animate({
                width: $(obj).innerWidth()
            },option.start_delay);
        },function () {
            var obj = $(this);
            $(obj).find('.top_0.left_0').stop(true).delay(option.end_delay).animate({
                height:'0px'
            },option.end_delay);
            $(obj).find('.bottom_0.left_0').stop(true).animate({
                width:'0px'
            },option.end_delay);
            $(obj).find('.bottom_0.right_0').stop(true).delay(option.end_delay).animate({
                height:'0px'
            },option.end_delay);
            $(obj).find('.top_0.right_0').stop(true).animate({
                width:'0px'
            },option.end_delay);
        });
        hborder.each(function(){
            $(this).addClass("rel");
            $(this).append("<span class='dis_block abs zindex_4 top_0 left_0 bor_title'></span>" +
                "<span class='dis_block abs zindex_4 bottom_0 left_0 bor_title'></span>" +
                "<span class='dis_block abs zindex_4 bottom_0 right_0 bor_title'></span>" +
                "<span class='dis_block abs zindex_4 top_0 right_0 bor_title'></span>");
            $(this).find('.top_0.left_0').css({
                "border-left": "solid "+option.border,
                "width": option.border,
                "height": option.border
            });
            $(this).find('.bottom_0.left_0').css({
                "border-top": "solid "+option.border,
                "width": option.border,
                "height": "0px"
            });
            $(this).find('.bottom_0.right_0').css({
                "border-right": "solid "+option.border,
                "width": option.border,
                "height": "0px"
            });
            $(this).find('.top_0.right_0').css({
                "border-bottom": "solid "+option.border,
                "width": "0px",
                "height": option.border
            });
        });
    };
}(jQuery));

/*-----------------------------------------------Andrew_Paging-------------------------------------------*/
(function($){
    //默认参数 (放在插件外面，避免每次调用插件都调用一次，节省内存)
    var defaults = {
        //id : '#paging',//id
        leng: 9,//总页数
        liClass: "",
        activeClass: '' ,//active类
        firstPage: '',//
        lastPage: '',
        prv: '«',
        next: '»',
        clickBack:function(){
        }
    };
    var opts,myOptions;
    //扩展
    $.fn.extend({
        //插件名称
        Andrew_Paging: function (options) {
            //覆盖默认参数
            myOptions = options;
            opts = $.extend(defaults, options);
            //主函数
            return this.each(function () {
                //激活事件
                var obj = $(this);
                var str1 = '';
                var str = '';
                var l = opts.leng;
                if (l > 1&&l < 10) {
                    str1 = '<li class="fl '+ opts.liClass +'"><a href="javascript:" class="page_active '+ opts.activeClass +'">1</a></li>';
                    for (i = 2; i < l + 1; i++) {
                        str += '<li class="fl '+ opts.liClass +'"><a href="javascript:">' + i + '</a></li>';
                    }
                }else if(l > 9){
                    str1 = '<li class="fl '+ opts.liClass +'"><a href="javascript:" class="page_active '+ opts.activeClass +'">1</a></li>';
                    for (i = 2; i < 10; i++) {
                        str += '<li class="fl '+ opts.liClass +'"><a href="javascript:">' + i + '</a></li>';
                    }
                    //str += '<li class="fl '+ opts.liClass +'"><a href="javascript:">...</a></li>'
                } else {
                    str1 = '<li class="fl '+ opts.liClass +'"><a href="javascript:" class="page_active '+ opts.activeClass +'">1</a></li>';
                }
                obj.html('<div class="next fr '+ opts.liClass.replace("bor_right_none","") +' ">' + opts.next + '</div><div class="last fr '+ opts.liClass +'">' + opts.lastPage + '</div><ul class="fr">' + str1 + str + '</ul><div class="first fr '+ opts.liClass +'">' + opts.firstPage + '</div><div class="prv fr '+ opts.liClass +'">' + opts.prv + '</div>');
                $(".page_active").css({"margin-top": "-1px"});
                obj.on('click', '.next', function () {
                    var pageshow = parseInt($(".page_active").html());
                    if(pageshow==l){
                        return false;
                    }
                    if(pageshow == l) {
                    }else if(pageshow > l-5&&pageshow < l){
                        $(".page_active").removeClass("page_active " + opts.activeClass).parent().next().find('a').addClass("page_active " + opts.activeClass);
                    }else if(pageshow > 0&&pageshow < 6){
                        $(".page_active").removeClass("page_active " + opts.activeClass).parent().next().find('a').addClass("page_active " + opts.activeClass);
                    }else {
                        $(".page_active").removeClass("page_active " + opts.activeClass).parent().next().find('a').addClass("page_active " + opts.activeClass);
                        fpageShow();
                    }
                    $(".page_active").css({"margin-top": "-1px"});
                    opts.clickBack(pageshow+1)
                });
                obj.on('click', '.prv', function () {
                    var pageshow = parseInt($(".page_active").html());
                    if (pageshow == 1) {
                        return false;
                    }else if(pageshow > l-5&&pageshow < l+1){
                        $(".page_active").removeClass("page_active " + opts.activeClass).parent().prev().find('a').addClass("page_active " + opts.activeClass);
                        //this.fpageBranch(pageshow-1);
                    }else if(pageshow > 1&&pageshow < 6){
                        $(".page_active").removeClass("page_active " + opts.activeClass).parent().prev().find('a').addClass("page_active " + opts.activeClass);
                        //this.fpageBranch(pageshow-1);
                    }else {
                        $(".page_active").removeClass("page_active " + opts.activeClass).parent().prev().find('a').addClass("page_active " + opts.activeClass);
                        //this.fpageBranch(pageshow-1);
                        fpageShow();
                    }
                    $(".page_active").css({"margin-top": "-1px"});
                    opts.clickBack(pageshow-1)
                });

                obj.on('click', '.first', function(){
                    var pageshow = 1;
                    var nowshow = parseInt($(".page_active").html());
                    $(".page_active").css({"margin-top": "-1px"});
                    if(nowshow==1){
                        return false;
                    }
                    $(".page_active").removeClass("page_active " + opts.activeClass).parent().prev().find('a').addClass("page_active " + opts.activeClass);
                    fpagePrv(0);
                    opts.clickBack(pageshow)
                });
                obj.on('click', '.last', function(){
                    l =opts.leng;
                    var pageshow = l;
                    var nowshow = parseInt($(".page_active").html());
                    if(nowshow==l){
                        return false;
                    }
                    if(l>9){
                        $(".page_active").removeClass("page_active " + opts.activeClass).parent().prev().find('a').addClass("page_active " + opts.activeClass);
                        fpageNext(8);
                    }else{
                        $(".page_active").removeClass("page_active " + opts.activeClass).parent().prev().find('a').addClass("page_active " + opts.activeClass);
                        fpageNext(l-1);
                    }
                    $(".page_active").css({"margin-top": "-1px"});
                    opts.clickBack(pageshow)
                });

                obj.on('click', 'li', function(){
                    var $this = $(this);
                    var pageshow = parseInt($this.find('a').html());
                    var nowshow = parseInt($(".page_active").html());
                    if(pageshow==nowshow){
                        return false;
                    }
                    if(l>9){
                        if(pageshow > l-5&&pageshow < l+1){
                            $(".page_active").removeClass("page_active " + opts.activeClass);
                            $this.find('a').addClass("page_active " + opts.activeClass);
                            fpageNext(8-(l-pageshow));
                        }else if(pageshow > 0&&pageshow < 5){
                            $(".page_active").removeClass("page_active " + opts.activeClass);
                            $this.find('a').addClass("page_active " + opts.activeClass);
                            fpagePrv(pageshow-1);
                        }else{
                            $(".page_active").removeClass("page_active " + opts.activeClass);
                            $this.find('a').addClass("page_active " + opts.activeClass);
                            fpageShow();
                        }
                    }else{
                        $(".page_active").removeClass("page_active " + opts.activeClass);
                        $this.find('a').addClass("page_active " + opts.activeClass);
                    }
                    $(".page_active").css({"margin-top": "-1px"});
                    opts.clickBack(pageshow)
                });

                function fpageShow(){
                    var pageshow = parseInt($(".page_active").html());
                    var pageStart = pageshow - 4;
                    var pageEnd = pageshow + 5;
                    var str1 = '';
                    for(i=0;i<9;i++){
                        str1 += '<li class="fl '+ opts.liClass +'"><a href="javascript:">' + (pageStart+i) + '</a></li>'
                    }
                    obj.find('ul').html(str1);
                    obj.find('ul li').eq(4).find('a').addClass("page_active " + opts.activeClass);
                    $(".page_active").css({"margin-top": "-1px"});
                }
                function fpagePrv(prv){
                    var str1 = '';
                    if(l>8){
                        for(i=0;i<9;i++){
                            str1 += '<li class="fl '+ opts.liClass +'"><a href="javascript:">' + (i+1) + '</a></li>'
                        }
                    }else{
                        for(i=0;i<l;i++){
                            str1 += '<li class="fl '+ opts.liClass +'"><a href="javascript:">' + (i+1) + '</a></li>'
                        }
                    }
                    obj.find('ul').html(str1);
                    obj.find('ul li').eq(prv).find('a').addClass("page_active " + opts.activeClass);
                    $(".page_active").css({"margin-top": "-1px"});
                }
                function fpageNext(next){
                    var str1 = '';
                    if(l>8){
                        for(i=l-8;i<l+1;i++){
                            str1 += '<li class="fl '+ opts.liClass +'"><a href="javascript:">' + i + '</a></li>'
                        }
                        obj.find('ul').html(str1);
                        obj.find('ul li').eq(next).find('a').addClass("page_active " + opts.activeClass);
                    }else{
                        for(i=0;i<l;i++){
                            str1 += '<li class="fl '+ opts.liClass +'"><a href="javascript:">' + (i+1) + '</a></li>'
                        }
                        obj.find('ul').html(str1);
                        obj.find('ul li').eq(next).find('a').addClass("page_active " + opts.activeClass);
                    }
                    $(".page_active").css({"margin-top": "-1px"});
                }
            });
        },
        setLength: function(newLength){
            myOptions.leng = newLength;
            $(this).html('');
            $(this).unbind();
            $(this).Andrew_Paging(myOptions)
        }
    })
}(jQuery));

/*-----------------------------------------------Andrew_Favorite-------------------------------------------*/
(function($){
    $.fn.Andrew_Favorite = function(setting) {
        var options = $.extend({
                likeMode: true, //是否开启点赞模式 （设置false为收藏模式）
                str: "+1",  //字符串，要显示的内容;也可以传一段html
                icon_defaultClass: 'dis_inbl text_12em iconfont icon-xihuan1', //default 类样式定义
                icon_changeClass: 'dis_inbl text_12em iconfont icon-xihuan', //change 类样式定义
                textClass: "c_white text_12em ml_02em mr_02em", //文字样式
                text_default: "Favorite", //默认显示的文字
                text_change: "Cancel", //点击后显示的文字
                startSize: "12px",  //动画开始的文字大小
                endSize: "30px",    //动画结束的文字大小
                interval: 600,  //动画时间间隔
                color: "red",    //文字颜色
                callback: function () { } //回调函数
            },
            setting);
        var that = $(this);
        that.each(function(){
            $(this).children("i").css({
                "*display":"inline",
                "*zoom":"1"
            });
            if (options.likeMode == true) {
                $(this).append('<i></i><span></span>(<em></em>)');
                $(this).children("i").addClass(options.icon_defaultClass);
                $(this).children("span").addClass(options.textClass).text(options.text_default);
                $(this).children("em").text($(this).attr("data-value"));
            } else {
                $(this).append('<i></i><span></span>');
                $(this).children("i").addClass(options.icon_defaultClass);
                $(this).children("span").addClass(options.textClass).text(options.text_default);
            }
        });
        that.on("click", function(e){
            e.preventDefault();
            var ele = $(this);
            if (options.likeMode == true) {
                if(typeof($(this).attr("favorite"))!="undefined"){
                    if($(this).attr("favorite")==1){
                        return false;
                    }
                    $(this).attr("favorite",1);
                }
                var count = parseInt($(this).attr("data-value"))+1;
                $(this).attr("data-value",count);
                $(this).find("em").text(count);
                $(this).children("i").removeClass(options.icon_defaultClass);
                $(this).children("i").addClass(options.icon_changeClass);
                $("body").append("<span class='ak-NumLength press'>" + options.str + "</span>");
                var box = $(".ak-NumLength");
                var left = $(this).offset().left + that.width() / 2;
                var top = $(this).offset().top - (that.height() / 2);
                box.css({
                    "position": "absolute",
                    "left": left + "px",
                    "top": top + "px",
                    "z-index": 9999,
                    "font-size": options.startSize,
                    "line-height": options.endSize,
                    "color": options.color
                });
                box.animate({
                    "font-size": options.endSize,
                    "opacity": "0",
                    "top": top - parseInt(options.endSize) + "px"
                }, options.interval, function () {
                    box.remove();
                    options.callback(count,ele);
                });
            } else {
                if ($(this).children("i").hasClass(options.icon_changeClass)) {
                    var count = parseInt($(this).attr("data-value"))-1;
                } else {
                    var count = parseInt($(this).attr("data-value"))+1;
                }
                if ($(this).children("span").text() == options.text_default ) {
                    $(this).children("span").text(options.text_change);
                } else {
                    $(this).children("span").text(options.text_default);
                }
                $(this).attr("data-value",count);
                $(this).children("i").toggleClass(options.icon_defaultClass+" "+options.icon_changeClass);
                options.callback(count,ele);
            }
        });
    };
}(jQuery));

/*-----------------------------------------------Andrew_ProductPhoto-------------------------------------------*/
(function($){
    var defaluts = {
        large_elem: ".plug_large_box",
        small_elem: ".plug_small_box",
        large_size_w: "",
        large_size_h: "",
        small_size: "",
        state: "bor_title border2",
        speed: "normal",
        vis: 4
    };
    $.fn.extend({
        "Andrew_ProductPhoto": function(options) {
            var opts = $.extend({},
                defaluts, options);
            return this.each(function() {
                var $this = $(this);
                var $small_list = $(opts.small_elem).children("div");
                var t = 0;
                $this.find("img").css({"width":"100%","min-height":"100%"});
                $(opts.large_elem).css({"width":opts.large_size_w+"em","height":opts.large_size_h+"em","margin-bottom":"10px"});
                $(opts.large_elem).find("ul li").eq(0).show();
                $small_list.find("ul li").css({"width":opts.small_size+"em","height":opts.small_size+"em","margin-right":"10px"});
                $small_list.find("ul li").eq(0).addClass(opts.state);
                var l = $small_list.find("ul li").length;
                var l_mean;
                if (l < opts.vis) {
                    l_mean = 0;
                    $small_list.parent().find("button").hide();
                    $small_list.addClass("ml_0");
                } else {
                    l_mean = ((parseInt(l / opts.vis) - 1) * opts.vis) + (l % opts.vis);
                }
                var w = $small_list.find("ul li").outerWidth(true);
                var ChangeBtn = $(opts.small_elem).find("button");
                $small_list.css({"width":w * opts.vis,"height":opts.small_size+"em"});
                $small_list.css({"margin-left": ($(opts.large_elem).outerWidth() - $small_list.outerWidth())/2+5});
                $small_list.find("ul").css({"width": l * w,"height":opts.small_size+"em"});
                $(opts.small_elem).css({"width":$(opts.large_elem).outerWidth(),"height":opts.small_size+"em"});
                $small_list.prev("button").css({"margin-right":"10px"});
                ChangeBtn.css({"width":($(opts.small_elem).outerWidth() - $small_list.outerWidth()) /2,"height":opts.small_size+"em","max-width": "2.8em"});
                $small_list.find("ul li").unbind("click");
                $small_list.find("ul li").click(function() {
                    $(this).addClass(opts.state).siblings().removeClass(opts.state);
                    t = $(this).index();
                    Img($(this).index())
                });
                $small_list.prev("button").unbind("click");
                $small_list.prev("button").click(function() {
                    var i;
                    $small_list.find("ul li").each(function(index) {
                        if ($(this).hasClass(opts.state)) {
                            i = index
                        }
                    });
                    i--;
                    if (i < 0) {
                        i = l - 1
                    }
                    t = i;
                    Img(i)
                });
                $small_list.next("button").unbind("click");
                $small_list.next("button").click(function() {
                    var i;
                    $small_list.find("ul li").each(function(index) {
                        if ($(this).hasClass(opts.state)) {
                            i = index
                        }
                    });
                    i++;
                    if (i > l - 1) {
                        i = 0
                    }
                    t = i;
                    Img(i)
                });
                function Img(i) {
                    $(opts.large_elem).find("ul li").eq(i).fadeIn().siblings().hide();
                    $small_list.find("ul li").eq(i).addClass(opts.state).siblings().removeClass(opts.state);
                    var ml = i * w;
                    if (ml <= l_mean * w) {
                        $small_list.find("ul").stop().animate({
                                marginLeft: -ml + "px"
                            },
                            opts.speed)
                    } else {
                        $small_list.find("ul").stop().animate({
                                marginLeft: -(l_mean * w) + "px"
                            },
                            opts.speed)
                    }
                }
                var timing = setInterval(function() {
                        t++;
                        if (t > l - 1) {
                            t = 0
                        }
                        Img(t)
                    },
                    3000);
                $this.hover(function() {
                        clearInterval(timing)
                    },
                    function() {
                        timing = setInterval(function() {
                                t++;
                                if (t > l - 1) {
                                    t = 0
                                }
                                Img(t)
                            },
                            3000)
                    })
            })
        }
    })
}(jQuery));

/*-----------------------------------------------Andrew_Readmore-------------------------------------------*/
(function($){
    $.fn.Andrew_Readmore = function(setting) {
        var option = $.extend({
                dom: "",
                icon_default: "",
                icon_active: ""
            },
            setting);
        var more = $(this);
        more.each(function() {
            more.append("<i class='"+option.icon_default+"'></i>");
            $(option.dom).hide();
            more.click(function() {
                $(option.dom).toggleClass('ak-is_active');
                more.children("i").toggleClass(option.icon_default + " " + option.icon_active);
                if ($(option.dom).hasClass('ak-is_active')) {
                    $(option.dom).slideDown();
                } else {
                    $(option.dom).slideUp();
                }
            });
        });
    };
}(jQuery));

/*-----------------------------------------------Andrew_Addition-------------------------------------------*/
(function($){
    $.fn.Andrew_Addition = function(setting) {
        var option = $.extend({
                add_btn: "",
                del_btn: "",
                num_title: "",
                show_count: "",
                alert_config: new Array(),
                confirm_config: new Array(),
                addback:function(){
                },
                delback:function(){
                }
            },
            setting);
        var that = $(this);
        var ele = that.children(":first");
        var count = 1;
        that.find(option.num_title).text(count);
        that.find(option.del_btn).on('click', function(){
            $ak.alert(option.alert_config[0], {
                title: option.alert_config[1],
                button_ok: option.alert_config[2],
                icon: "error",
                animateIn: "bounceInDown",
                animateOut: "bounceOutUp"
            });
        });
        $(option.add_btn).on('click', function(){
            var length = that.children().length;
            if (length < option.show_count) {
                count++;
                that.append(ele.clone(true));
                var that_last = that.children(":last");
                that_last.find(option.num_title).text(count);
                that_last.find(option.del_btn).on('click', deleteMethod);
                option.addback(count,that_last)
            } else {
                $(this).attr("disabled","disabled");
            }
        });
        ele.find(option.del_btn).on('click', deleteMethod);
        var deleteMethod = function(){
            var length = that.children().length;
            var del = $(this);
            if(length > 1){
                count--;
                $ak.confirm(option.confirm_config[0], {
                    title: option.confirm_config[1],
                    button_ok: option.confirm_config[2],
                    button_cancel: option.confirm_config[3],
                    icon: "question",
                    animateIn : "bounceInDown",
                    animateOut: "bounceOutUp",
                    onSubmit:function(res){
                        webToast(option.confirm_config[4],"bottom",1000);
                        option.delback(del);
                    },
                    onCancel:function (res) {
                        webToast(option.confirm_config[5],"bottom",1000);
                    }
                });
                that.children().each(function(i){
                    var temp = i + 1;
                    $(this).find(option.num_title).text(temp);
                    $(option.add_btn).removeAttr("disabled");
                });
            }
        }
    };
}(jQuery));

/*-----------------------------------------------Andrew_ToolTip-------------------------------------------*/
(function($){
    $.fn.Andrew_ToolTip = function(options) {
        //Providing plugin defaults
        var defaults = {
                background: '#777777',
                color: '#ffffff',
                opacity: '0.8'
            },
            options = $.extend(defaults, options);
        // Always return the jQuery object to allow for chainability.
        return this.each(function() {
            var elem = $(this);
            //grab the title attribute
            var title = elem.attr('title');
            //only show the Andrew_ToolTip when the title is not empty
            if(title != '') {
                //creating the Andrew_ToolTip div
                var tooltip = $('<div class="ak-tooltip" />');
                //Remove the title attribute's to avoid the native Andrew_ToolTip from the browser
                elem.attr('title','');
                // mouse over
                elem.hover(function(e) {
                        tooltip.hide().appendTo('body').html(title).hide().css({
                            'background-color' : options.background,
                            'color' : options.color,
                            'opacity' : options.opacity
                        })
                            .fadeIn(500);
                    },
                    // mouse out
                    function() {
                        tooltip.remove(); //remove the Andrew_ToolTip
                    });
            }
            //mouse move the Andrew_ToolTip will follow the cursor
            //get X & Y position of the cursor
            elem.mousemove(function(e) {
                tooltip.css({
                    top: e.pageY - tooltip.outerHeight() - 10,
                    left: e.pageX - (tooltip.outerWidth()/2) + 2
                });
            });
        });
    }
}(jQuery));

/*-----------------------------------------------Andrew_IntlTelInput-------------------------------------------*/
(function($){
    $.fn.Andrew_IntlTelInput = function(setting) {
        var option = $.extend({
                dom:"",
                Nav_Class:"",
                Nav_active: "",
                List_Class: "",
                data_url:"",
                width: "",
                maxheight:"",
                clickBack:function(){
                }
            },
            setting);
        function TelInput(el) {
            this.el = el;
            this.initEvents();
        }
        TelInput.prototype = {
            initEvents : function() {
                var obj = this;
                obj.el.each(function() {
                    $(this).after("<span />");
                    $(this).next("span").css({
                        "display": "block",
                        "position": "absolute",
                        "top": "50%",
                        "left": $(this).outerWidth()-26,
                        "margin-top": "-0.2em",
                        "border-top": "0.6em solid #777777",
                        "border-right": "0.6em solid transparent",
                        "border-left": "0.6em solid transparent",
                        "border-bottom": "none"
                    });
                    $('body').append("<div id='"+option.dom.substring(1,option.dom.length)+"' class='"+option.dom.substring(1,option.dom.length)+" abs bg_white border bor_gray_ddd dis_none zindex_6'><datalist></datalist></div>");
                    var objsub = $(option.dom);
                    var datalist = objsub.children("datalist");
                    datalist.before("<ol>\n" +
                        "<li class='"+option.Nav_active+"'>HOT</li>\n" +
                        "<li>A</li>\n" +
                        "<li>B</li>\n" +
                        "<li>D</li>\n" +
                        "<li>E</li>\n" +
                        "<li>F</li>\n" +
                        "<li>G</li>\n" +
                        "<li>H</li>\n" +
                        "<li>J</li>\n" +
                        "<li>K</li>\n" +
                        "<li>L</li>\n" +
                        "<li>M</li>\n" +
                        "<li>N</li>\n" +
                        "<li>P</li>\n" +
                        "<li>R</li>\n" +
                        "<li>S</li>\n" +
                        "<li>T</li>\n" +
                        "<li>W</li>\n" +
                        "<li>X</li>\n" +
                        "<li>Y</li>\n" +
                        "<li>Z</li>\n" +
                        "</ol>");
                    var flag = false;
                    htmlobjs=$.ajax({
                        type : "POST",
                        url: option.data_url,
                        async:false,
                        cache: false,
                        success:function () {
                            flag = true;
                        },
                        error:function () {
                            flag = false;
                            webToast("Ajax Load Error!","middle",2000);
                        }
                    });
                    datalist.html(htmlobjs.responseText);
                    var objsub_ol = objsub.find("ol");
                    var objsub_ul = objsub.find("ul");
                    objsub.hide();
                    objsub.css({
                        "width": option.width,
                        "top": obj.el.offset().top + obj.el.outerHeight(),
                        "left": obj.el.offset().left,
                        "overflow": "hidden"
                    });
                    datalist.css({
                        "display": "block",
                        "padding-top": "2.4em",
                        "overflow-y": "scroll",
                        "max-height":option.maxheight
                    });
                    objsub_ol.css({
                        "overflow": "hidden",
                        "position": "absolute"
                    });
                    objsub_ul.css({
                        "width": "100%",
                        "overflow": "hidden"
                    });
                    objsub_ol.find("li").addClass(option.Nav_Class);
                    objsub_ul.find("li").addClass(option.List_Class);
                    objsub_ul.find("li").css({
                        "cursor": "pointer"
                    });
                    objsub_ul.fadeOut();
                    objsub_ul.eq(0).fadeIn();
                    objsub_ol.find("li").on('click', function(event){
                        event.stopPropagation();
                        objsub.show();
                        objsub_ol.find("li").removeClass(option.Nav_active);
                        objsub_ol.find("li").eq($(this).index()).addClass(option.Nav_active);
                        objsub_ul.fadeOut();
                        objsub_ul.eq($(this).index()).fadeIn();
                        datalist.animate({scrollTop:0},0);
                    });
                    objsub_ul.find("li").hover(function(){
                        $(this).addClass("bg_gray_f5f");
                    },function(){
                        $(this).removeClass("bg_gray_f5f");
                    });
                    objsub_ul.find("li").on('click', function(){
                        var val = this;
                        obj.el.val($(this).text());
                        objsub.slideUp();
                        option.clickBack(val);
                    });
                    $(this).on('click', function(event){
                        $(this).toggleClass('ak-is_active');
                        $(this).next("span").toggleClass('open');
                        if ($(this).next("span").hasClass('open')) {
                            $(this).next("span").css({
                                "border-bottom": "0.6em solid #777777",
                                "border-top": "none"
                            });
                        } else {
                            $(this).next("span").css({
                                "border-bottom": "none",
                                "border-top": "0.6em solid #777777"
                            });
                        }
                        if ($(this).hasClass('ak-is_active')) {
                            objsub.slideDown();
                        } else {
                            objsub.slideUp();
                        }
                        event.stopPropagation();
                    });
                    $(document).click(function() {
                        obj.el.removeClass('ak-is_active');
                        obj.el.next("span").removeClass('open');
                        obj.el.next("span").css({
                            "border-bottom": "none",
                            "border-top": "0.6em solid #777777"
                        });
                        objsub.slideUp();
                    });
                });
            }
        };
        var el = new TelInput( $(this) );
    };
}(jQuery));

/*-----------------------------------------------Andrew_SnInput-------------------------------------------*/
(function($){
    $.fn.Andrew_SnInput = function(setting) {
        var option = $.extend({
                input_length: 1,
                callback:function(){
                }
            },
            setting);
        var ele = $(this).find("input");
        $(this).css({
            "padding-left": ($(this).outerWidth() - ele.eq(0).outerWidth()*(ele.length+1))/2
        });
        ele.each(function() {
            ele.attr("maxlength",option.input_length);
            ele.eq(0).focus(); //第一个元素显示光标，自动跳到下一个输入框
            $(this).keyup(function(e) {
                e = window.event || e;
                var k = e.keyCode || e.which;
                if (k == 8) { //8是空格键
                    if ($(this).val().length < 1) {
                        $(this).prev().focus();
                        $(this).prev().focus(function() {
                            var obj = e.srcElement ? e.srcElement: e.target;
                            if (obj.createTextRange) { //IE浏览器
                                var range = obj.createTextRange();
                                range.moveStart("character", option.input_length);
                                range.collapse(true);
                                range.select();
                            }
                        });
                    }
                } else {
                    if ($(this).val().length > parseInt(option.input_length)-1) {
                        $(this).next().focus();
                    }
                }
                this.value=this.value.replace(/[^a-z0-9]/i,''); //只允许输入字母和数字
                this.value=this.value.toUpperCase(); //英文字母转换为大写
            })
        });
        ele.bind('keyup',function() {
            var f = true;
            var str = "";
            for(var i = 0;i < ele.length; i++){
                if(""==ele.eq(i).val()){
                    f = false;
                }
            }
            if(f){
                for(var i = 0;i < ele.length; i++){
                    str += ele.eq(i).val();
                }
                if(str.length==(parseInt(option.input_length)*ele.length)){
                    option.callback(str)
                }
            }else{
                option.callback("");
            }
        });
    };
}(jQuery));

/*-----------------------------------------------Andrew_FocusChange-------------------------------------------*/
/*(function($){
    $.fn.Andrew_FocusChange=function(options){
        var defalutes={
            'boxWidth':160,
            'boxHeight':80,
            'changeLen':5,
            'changeSpend':300,
            'autoChange':true,
            'changeHandle':true,
            'autoTime':5000,
            'activeClass': "",
            'btnClass': "",
            clickBack:function(){
            },
            PrevCallBack:function(){
            },
            NextCallBack:function(){
            }
        };
        var ops=$.extend(defalutes, options),
            $that=$(this);
        var _html='<button type="button">&lt;</button><button type="button">&gt;</button>';
        var $changeBox=$that.children(),
            $changeUl=$changeBox.find("ul"),
            $changeLi=$changeBox.find("li"),
            $changePrev='',
            $changeNext='',
            _len=$changeLi.length,
            _timer='';
        $changeLi.css({
            "width":ops.boxWidth,
            "height":ops.boxHeight-1,
            "overflow": "hidden",
            "float": "left"
        });
        $changeUl.css({
            "position":"absolute",
            "top": 0,
            "height":ops.boxHeight,
            "overflow": "hidden"
        });
        $changeBox.css({
            "width":$changeLi.outerWidth()*ops.changeLen,
            "height":ops.boxHeight,
            "overflow": "hidden"
        });
        $changeLi.eq(0).addClass(ops.activeClass);
        if(ops.changeHandle){
            $that.append(_html);
            $that.find("button").addClass(ops.btnClass);
            $changePrev=$that.find("button").eq(0);
            $changeNext=$that.find("button").eq(1);
            var bor_width = $changeLi.eq(0).outerWidth() - $changeLi.eq(0).width() +1;
            $changePrev.css({
                "position":"absolute",
                "left": 0,
                "top": 0,
                "width": ($that.outerWidth()-$changeBox.outerWidth())/2+bor_width,
                "height":ops.boxHeight,
                "overflow": "hidden"
            });
            $changeNext.css({
                "position":"absolute",
                "right": 0,
                "top": 0,
                "width": ($that.outerWidth()-$changeBox.outerWidth())/2+bor_width,
                "height":ops.boxHeight,
                "overflow": "hidden"
            });
        }
        var oWidth=$changeLi.eq(0).outerWidth(),
            bWidth=oWidth*_len,
            _handle=true;
            $changeUl.width(bWidth);
        ActiveElement();
        $changeNext.on("click",function(){
            if(_handle){
                _handle=false;
                clearInterval(_timer);
                $changeUl.css('right','auto');
                for(var i=0; i<ops.changeLen; i++){
                    var _li=$changeUl.find("li").eq(i).clone(true);
                    $changeUl.append(_li);
                }
                $changeUl.stop().animate({
                    'left':-oWidth*ops.changeLen
                },300,function(){
                    for(var i=0; i<ops.changeLen; i++){
                        $changeUl.find("li").eq(0).remove();
                    }
                    ops.NextCallBack($changeUl.find("li").eq(0));
                    $changeUl.find("li").removeClass(ops.activeClass);
                    $changeUl.find("li").eq(0).addClass(ops.activeClass);
                    $changeUl.css('left',0);
                    _handle=true;
                });
                autoPlay();
                ActiveElement();
            }
        });
        var _len1=_len-1;
        $changePrev.on("click",function(){
            $changeUl.css('right',0);
            if(_handle){
                _handle=false;
                clearInterval(_timer);
                $changeUl.css('left','auto');
                for(var i=0; i<ops.changeLen; i++){
                    var $_li=$changeUl.find("li").eq(_len1).clone(true);
                    $changeUl.prepend($_li);
                }

                $changeUl.stop().animate({
                    'right':-oWidth*(_len-ops.changeLen)
                },300,function(){
                    for(var i=0; i<ops.changeLen; i++){
                        $changeUl.find("li").eq(_len).remove();
                    }
                    ops.PrevCallBack($changeUl.find("li").eq(0));
                    $changeUl.find("li").removeClass(ops.activeClass);
                    $changeUl.find("li").eq(0).addClass(ops.activeClass);
                    _handle=true;
                });
                autoPlay();
                ActiveElement();
            }
        });
        function autoPlay(){
            if(ops.autoChange){
                _timer=setInterval(function(){
                    $changeNext.click();
                },ops.autoTime)
            }
        }
        function ActiveElement(){
            $changeUl.find("li").on("click",function(e){
                e.stopPropagation();
                $changeUl.find("li").removeClass(ops.activeClass);
                $changeUl.find("li").eq($(this).index()).addClass(ops.activeClass);
                ops.clickBack($changeUl.find("li").eq($(this).index()));
            });
        }
        autoPlay();
        return this;
    }
}(jQuery));*/

(function($){
    $.fn.Andrew_FocusChange=function(options){
        var defalutes={
            'boxWidth':160,
            'boxHeight':80,
            'changeLen':5,
            'changeSpend':300,
            'autoChange':true,
            'changeHandle':true,
            'autoTime':5000,
            'activeClass': "",
            'btnClass': "",
            'choseIndex':0,
            'outUsed':true,
            'defaultDate':"",
            'leftBtnStatus':false,
            clickBack:function(){
            },
            PrevCallBack:function(){
            },
            NextCallBack:function(){
            }

        };
        var ops=$.extend(defalutes, options),
            $that=$(this);
        var _html='<button type="button">&lt;</button><button type="button">&gt;</button>';
        var $changeBox=$that.children(),
            $changeUl=$changeBox.find("ul"),
            $changeLi=$changeBox.find("li"),
            $changePrev='',
            $changeNext='',
            _len=$changeLi.length,
            _timer='';
        $changeLi.css({
            "width":ops.boxWidth,
            "height":ops.boxHeight-1,
            "overflow": "hidden",
            "float": "left",
        });
        $changeUl.css({
            "position":"absolute",
            "top": 0,
            "height":ops.boxHeight,
            "overflow": "hidden"
        });
        $changeBox.css({
            "width":$changeLi.outerWidth()*ops.changeLen,
            "height":ops.boxHeight,
            "overflow": "hidden"
        });
        var choseIndex = (ops.choseIndex!=null &&  ops.choseIndex!=undefined && ops.choseIndex!="")?ops.choseIndex:0;
        $changeLi.eq(choseIndex).addClass(ops.activeClass);
        ops.defaultDate =  $changeLi.eq(choseIndex).find("div").find("strong").eq(0).text();
        if(ops.changeHandle){
            $that.append(_html);
            $that.find("button").addClass(ops.btnClass);
            $changePrev=$that.find("button").eq(0);
            if("false"==ops.leftBtnStatus){
                $changePrev.attr("disabled","disabled");
            }
            $changeNext=$that.find("button").eq(1);
            var bor_width = $changeLi.eq(0).outerWidth() - $changeLi.eq(0).width() +1
            $changePrev.css({
                "position":"absolute",
                "left": 0,
                "top": 0,
                "width": ($that.outerWidth()-$changeBox.outerWidth())/2+bor_width,
                "height":ops.boxHeight,
                "overflow": "hidden"
            });
            $changeNext.css({
                "position":"absolute",
                "right": 0,
                "top": 0,
                "width": ($that.outerWidth()-$changeBox.outerWidth())/2+bor_width,
                "height":ops.boxHeight,
                "overflow": "hidden"
            });
        };
        var oWidth=$changeLi.eq(choseIndex).outerWidth(),
            bWidth=oWidth*_len,
            _handle=true;
        $changeUl.width(bWidth);
        ActiveElement();

        $changeNext.on("click",function(){
            ops.NextCallBack($changeUl,$that.find("button").eq(0),ops.defaultDate);
            setNextDatails();
        });
        var _len1=_len-1;
        $changePrev.on("click",function(){
            ops.PrevCallBack($changeUl,$that.find("button").eq(0),ops.defaultDate);
            setPreDatails();
        });

        function setPreDatails() {
            $changeUl.css('right',0);
            if(_handle){
                _handle=false;
                clearInterval(_timer);
                $changeUl.css('left','auto');
                if(!ops.outUsed){
                    for(var i=0; i<ops.changeLen; i++){
                        var $_li=$changeUl.find("li").eq(_len1).clone(true);
                        $changeUl.prepend($_li);
                    };
                }
                $changeUl.stop().animate({
                    'right':-oWidth*(_len-ops.changeLen)
                },300,function(){
                    for(var i=0; i<ops.changeLen; i++){
                        $changeUl.find("li").eq(_len).remove();
                    };
                    $changeUl.find("li").each(function(){
                        var flag = (ops.defaultDate == $changeUl.find("li").eq($(this).index()).find("div").find("strong").eq(0).text());
                        if(flag){
                            $changeUl.find("li").eq($(this).index()).removeClass(ops.activeClass);
                            $changeUl.find("li").eq($(this).index()).addClass(ops.activeClass);
                        }else{
                            $changeUl.find("li").eq($(this).index()).removeClass(ops.activeClass);
                        }
                    });
                    _handle=true;
                });
                autoPlay();
                ActiveElement();
            };
        }

        function setNextDatails() {
            if(_handle){
                _handle=false;
                clearInterval(_timer);
                $changeUl.css('right','auto');
                if(!ops.outUsed){
                    for(var i=0; i<ops.changeLen; i++){
                        var _li=$changeUl.find("li").eq(i).clone(true);
                        $changeUl.append(_li);
                    };
                }
                $changeUl.stop().animate({
                    'left':-oWidth*ops.changeLen
                },300,function(){
                    for(var i=0; i<ops.changeLen; i++){
                        $changeUl.find("li").eq(0).remove();
                    };
                    $changeUl.children("li").each(function(){
                        var flag = (ops.defaultDate == $changeUl.find("li").eq($(this).index()).find("div").find("strong").eq(0).text());
                        if(flag){
                            $changeUl.find("li").eq($(this).index()).removeClass(ops.activeClass);
                            $changeUl.find("li").eq($(this).index()).addClass(ops.activeClass);
                        }else{
                            $changeUl.find("li").eq($(this).index()).removeClass(ops.activeClass);
                        }
                    });
                    $changeUl.css('left',0);
                    _handle=true;
                });
                autoPlay();
                ActiveElement();
            };
        }
        function autoPlay(){
            if(ops.autoChange){
                _timer=setInterval(function(){
                    $changeNext.click();
                },ops.autoTime)
            }
        }
        function ActiveElement(){
            //解绑事件，否则重复
            $changeUl.find("li").unbind();
            $changeUl.find("li").on("click",function(e){
                e.stopPropagation();
                ops.defaultDate =  $changeUl.find("li").eq($(this).index()).find("div").find("strong").eq(0).text();
                $changeUl.find("li").removeClass(ops.activeClass);
                $changeUl.find("li").eq($(this).index()).addClass(ops.activeClass);
                ops.clickBack($changeUl.find("li").eq($(this).index()));
            });
        }
        autoPlay();
        return this;
    }
}(jQuery));

/*-----------------------------------------------Andrew_Typeahead-------------------------------------------*/
(function($){
    var Andrew_Typeahead = function (element, options) {
        this.$element = $(element);
        this.options = $.extend(true, {}, $.fn.Andrew_Typeahead.defaults, options);
        this.$menu = $(this.options.menu).appendTo('body');
        this.shown = false;
        // Method overrides
        this.eventSupported = this.options.eventSupported || this.eventSupported;
        this.grepper = this.options.grepper || this.grepper;
        this.highlighter = this.options.highlighter || this.highlighter;
        this.lookup = this.options.lookup || this.lookup;
        this.matcher = this.options.matcher || this.matcher;
        this.render = this.options.render || this.render;
        this.select = this.options.select || this.select;
        this.sorter = this.options.sorter || this.sorter;
        this.source = this.options.source || this.source;
        if (!this.source.length) {
            var ajax = this.options.ajax;
            if (typeof ajax === 'string') {
                this.ajax = $.extend({}, $.fn.Andrew_Typeahead.defaults.ajax, { url: ajax });
            } else {
                this.ajax = $.extend({}, $.fn.Andrew_Typeahead.defaults.ajax, ajax);
            }
            if (!this.ajax.url) {
                this.ajax = null;
            }
        }
        this.listen();
    };
    Andrew_Typeahead.prototype = {
        constructor: Andrew_Typeahead,
        //  Check if an event is supported by the browser eg. 'keypress'
        eventSupported: function(eventName) {
            var isSupported = (eventName in this.$element);

            if (!isSupported) {
                this.$element.setAttribute(eventName, 'return;');
                isSupported = typeof this.$element[eventName] === 'function';
            }

            return isSupported;
        },
        //  Handle AJAX source
        ajaxer: function () {
            var that = this,
                query = that.$element.val();
            if (query === that.query) {
                return that;
            }
            // Query changed
            that.query = query;
            // Cancel last timer if set
            if (that.ajax.timerId) {
                clearTimeout(that.ajax.timerId);
                that.ajax.timerId = null;
            }
            if (!query || query.length < that.ajax.triggerLength) {
                // Cancel the ajax callback if in progress
                if (that.ajax.xhr) {
                    that.ajax.xhr.abort();
                    that.ajax.xhr = null;
                    that.ajaxToggleLoadClass(false);
                }

                return that.shown ? that.hide() : that;
            }
            // Query is good to send, set a timer
            that.ajax.timerId = setTimeout(function() {
                $.proxy(that.ajaxExecute(query), that)
            }, that.ajax.timeout);
            return that;
        },
        //  Execute an AJAX request
        ajaxExecute: function(query) {
            this.ajaxToggleLoadClass(true);

            // Cancel last call if already in progress
            if (this.ajax.xhr) this.ajax.xhr.abort();

            var params = this.ajax.preDispatch ? this.ajax.preDispatch(query) : { query : query };
            var jAjax = (this.ajax.method === "post") ? $.post : $.get;
            this.ajax.xhr = jAjax(this.ajax.url, params, $.proxy(this.ajaxLookup, this));
            this.ajax.timerId = null;
        },
        //  Perform a lookup in the AJAX results
        ajaxLookup: function (data) {
            var items;

            this.ajaxToggleLoadClass(false);

            if (!this.ajax.xhr) return;

            if (this.ajax.preProcess) {
                data = this.ajax.preProcess(data);
            }

            // Save for selection retreival
            this.ajax.data = data;

            items = this.grepper(this.ajax.data);

            if (!items || !items.length) {
                return this.shown ? this.hide() : this;
            }

            this.ajax.xhr = null;

            return this.render(items.slice(0, this.options.items)).show();
        },
        //  Toggle the loading class
        ajaxToggleLoadClass: function (enable) {
            if (!this.ajax.loadingClass) return;
            this.$element.toggleClass(this.ajax.loadingClass, enable);
        },
        //  Search source
        lookup: function (event) {
            var that = this,
                items;

            if (that.ajax) {
                that.ajaxer();
            }
            else {
                that.query = that.$element.val();

                if (!that.query) {
                    return that.shown ? that.hide() : that;
                }

                items = that.grepper(that.source);

                if (!items || !items.length) {
                    return that.shown ? that.hide() : that;
                }

                return that.render(items.slice(0, that.options.items)).show();
            }
        },
        //  Filters relevent results
        grepper: function(data) {
            var that = this,
                items;

            if (data && data.length && !data[0].hasOwnProperty(that.options.display)) {
                return null;
            }
            //匡超修改了这里，去掉了排序和筛选。2018.1.17
            return data;
        },
        //  Looks for a match in the source
        matcher: function (item) {
            return ~item.toLowerCase().indexOf(this.query.toLowerCase());
        },
        //  Sorts the results
        sorter: function (items) {
            var that = this,
                beginswith = [],
                caseSensitive = [],
                caseInsensitive = [],
                item;
            //debugger;

            while (item = items.shift()) {
                if (!item[that.options.display].toLowerCase().indexOf(this.query.toLowerCase())) {
                    beginswith.push(item);
                }
                else if (~item[that.options.display].indexOf(this.query)) {
                    caseSensitive.push(item);
                }
                else {
                    caseInsensitive.push(item);
                }
            }

            return beginswith.concat(caseSensitive, caseInsensitive);
        },
        //  Shows the results list
        show: function () {
            var pos = $.extend({}, this.$element.offset(), {
                height: this.$element[0].offsetHeight
            });

            this.$menu.css({
                top: pos.top + pos.height,
                left: pos.left,
                width: this.$element.outerWidth()
            });

            this.$menu.slideDown();
            this.shown = true;

            return this;
        },
        //  Hides the results list
        hide: function () {
            this.$menu.slideUp();
            this.shown = false;
            return this;
        },
        //  Highlights the match(es) within the results
        highlighter: function (item) {
            var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
            return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
                return '<strong>' + match + '</strong>';
            });
        },
        //  Renders the results list
        render: function (items) {
            var that = this;

            items = $(items).map(function (i, item) {
                i = $(that.options.item).attr('data-value', item[that.options.val]);
                i.html(that.highlighter(item[that.options.display], item));
                return i[0];
            });

            items.first().addClass('ak-is_active');
            this.$menu.html(items);
            return this;
        },
        //  Item is selected
        select: function () {
            var $selectedItem = this.$menu.find('.ak-is_active');
            this.$element.val($selectedItem.text()).change();
            this.options.itemSelected($selectedItem, $selectedItem.attr('data-value'), $selectedItem.text());
            return this.hide();
        },
        //  Selects the next result
        next: function (event) {
            var active = this.$menu.find('.ak-is_active').removeClass('ak-is_active');
            var next = active.next();

            if (!next.length) {
                next = $(this.$menu.find('li')[0]);
            }

            next.addClass('ak-is_active');
        },
        //  Selects the previous result
        prev: function (event) {
            var active = this.$menu.find('.ak-is_active').removeClass('ak-is_active');
            var prev = active.prev();

            if (!prev.length) {
                prev = this.$menu.find('li').last();
            }

            prev.addClass('ak-is_active');
        },
        //  Listens for user events
        listen: function () {
            this.$element.on('blur', $.proxy(this.blur, this))
                .on('keyup', $.proxy(this.keyup, this));

            if (this.eventSupported('keydown')) {
                this.$element.on('keydown', $.proxy(this.keypress, this));
            } else {
                this.$element.on('keypress', $.proxy(this.keypress, this));
            }

            this.$menu.on('click', $.proxy(this.click, this))
                .on('mouseenter', 'li', $.proxy(this.mouseenter, this));
        },
        //  Handles a key being raised up
        keyup: function (e) {
            e.stopPropagation();
            e.preventDefault();
            switch (e.keyCode) {
                case 40:
                // down arrow
                case 38:
                    // up arrow
                    break;
                case 9:
                // tab
                case 13:
                    // enter
                    if (!this.shown) {
                        return;
                    }
                    this.select();
                    break;
                case 27:
                    // escape
                    this.hide();
                    break;
                default:
                    this.lookup();
            }
        },
        //  Handles a key being pressed
        keypress: function (e) {
            e.stopPropagation();
            if (!this.shown) {
                return;
            }
            switch (e.keyCode) {
                case 9:
                // tab
                case 13:
                // enter
                case 27:
                    // escape
                    e.preventDefault();
                    break;
                case 38:
                    // up arrow
                    e.preventDefault();
                    this.prev();
                    break;
                case 40:
                    // down arrow
                    e.preventDefault();
                    this.next();
                    break;
            }
        },
        //  Handles cursor exiting the textbox
        blur: function (e) {
            var that = this;
            e.stopPropagation();
            e.preventDefault();
            setTimeout(function () {
                if (!that.$menu.is(':focus')) {
                    that.hide();
                }
            }, 150)
        },
        //  Handles clicking on the results list
        click: function (e) {
            e.stopPropagation();
            e.preventDefault();
            this.select();
        },
        //  Handles the mouse entering the results list
        mouseenter: function (e) {
            this.$menu.find('.ak-is_active').removeClass('ak-is_active');
            $(e.currentTarget).addClass('ak-is_active');
        }
    };
    //  Plugin definition
    $.fn.Andrew_Typeahead = function (option) {
        return this.each(function () {
            var $this = $(this),
                data = $this.data('ak_typeahead'),
                options = typeof option === 'object' && option;

            if (!data) {
                $this.data('ak_typeahead', (data = new Andrew_Typeahead(this, options)));
            }

            if (typeof option === 'string') {
                data[option]();
            }
        });
    };
    //  Defaults
    $.fn.Andrew_Typeahead.defaults = {
        source: [],
        items: 8,
        menu: '<ul class="ak-typeahead"></ul>',
        item: '<li></li>',
        display: 'cityname',
        val: 'id',
        itemSelected: function () { },
        ajax: {
            url: null,
            timeout: 300,
            method: 'post',
            triggerLength: 3,
            loadingClass: null,
            displayField: null,
            preDispatch: null,
            preProcess: null
        }
    };
    $.fn.Andrew_Typeahead.Constructor = Andrew_Typeahead;
    $(function () {
        $('body').on('focus.ak_typeahead.data-api', '[data-provide="ak_typeahead"]', function (e) {
            var $this = $(this);
            if ($this.data('ak_typeahead')) {
                return;
            }
            e.preventDefault();
            $this.ak_typeahead($this.data());
        })
    });
}(jQuery));

/*-----------------------------------------------Andrew_ChooseList-------------------------------------------*/
(function($){
    // 默认实例化配置
    var defaults = {
        itemWidth: null,
        skin: '',
        multi: false,
        active: '',
        full: false, //Choose的宽度，默认为null将自动获取Choose的宽度；
        colNum: null, // 每行显示的个数
        dataKey: 'dataKey', //实例化后的data键值，方便后续通过data('dataKey')取出；
        change: null, //Choose值改变时的回调；
        click: null //Choose元素点击时的回调，diabled时不发生。
    };
    $.fn.Andrew_ChooseList = function(options) {
        var _this = $(this),
            _num = _this.length;
        // 当要实例的对象只有一个时，直接实例化返回对象；
        if (_num === 1) {
            return new ak_Choose(_this, options);
        }
        // 当要实例的对象有多个时，循环实例化，不返回对象；
        if (_num > 1) {
            _this.each(function(index, el) {
                new ak_Choose($(el), options);
            })
        }
        // 当元素个数为0时，不执行实例化。
    };
    /**
     * @param {[jQuery]} el  [jQuery选择后的对象，此处传入的为单个元素]
     * @param {[object]} opt [设置的参数]
     */
    function ak_Choose(el, opt) {
        this.el = el;
        this._tag = this.el.prop('tagName').toLowerCase();
        this._opt = $.extend({}, defaults, opt);

        return this._init();
    }

    // 原型链扩展。
    ak_Choose.prototype = {

        // init初始化;
        _init: function() {
            var _data = this.el.data(this._opt.dataKey);
            // 如果已经实例化了，则直接返回
            if (_data)
                return _data;
            else
                this.el.data(this._opt.dataKey, this);

            // 设置是否多选
            if (this._tag == 'select') {
                this.multi = this.el.prop('multiple');
            } else {
                this.multi = this.el.attr('multiple') ? !!this.el.attr('multiple') : this._opt.multi;
            }

            // 根据不同的标签进行不同的元素组建
            var _setFunc = this['_setHtml_' + this._tag];
            if (_setFunc) {
                _setFunc.call(this);
            }
            if (this._opt.full) {
                this._wrap.addClass('choose-flex');
            }
            this._wrap.addClass(this._opt.skin);
            if (this.multi && !this._opt.skin)
                this._wrap.addClass('choose-type-right');
            this._bindEvent(); // 绑定事件
        },

        // 组建并获取相关的dom元素-ul;
        _setHtml_ul: function() {
            this._wrap = this.el;
            this._items = this.el.children('li');
            if (this._opt.itemWidth) {
                this._items.css('width', this._opt.itemWidth);
            }
        },

        // 绑定事件；
        _bindEvent: function() {
            var _this = this;
            _this._wrap.on('click', 'li', function() {
                var _self = $(this);
                if (_self.hasClass('disabled'))
                    return;

                if (!_this.multi) { // single select
                    var _val = _self.attr('data-value') || _self.index();
                    _this.val(_val);
                    _this._triggerClick(_val, _self);
                } else { // multiple
                    _self.toggleClass(_this._opt.active);
                    var _val = [];
                    _this._items.each(function(index, el) {
                        var _el = $(this);
                        if (_el.hasClass(_this._opt.active)) {
                            var _valOrIndex = _this._tag == 'select' ? _el.attr('data-value') : _el.index();
                            _val.push(_valOrIndex);
                        }
                    });
                    _this.val(_val);
                    _this._triggerClick(_val, _self);
                }
            });
            return _this;
        },

        // change 触发；value：值 ；
        _triggerChange: function(value, item) {
            item = item || this._wrap;
            this.change(value, item);
            if (typeof this._opt.change == 'function')
                this._opt.change.call(this, value, item);
        },

        // click 触发；value：值 ；item：选中的option；
        _triggerClick: function(value, item) {
            this.click(value, item);
            if (typeof this._opt.click == 'function')
                this._opt.click.call(this, value, item);
        },

        // 获取或设置值:ul
        _val_ul: function(index) {
            // getValue
            if (arguments.length === 0) {
                var _oActive = this._wrap.children('li.' + this._opt.active);
                if (!this.multi) { // single select
                    return _oActive.index() == -1 ? null : _oActive.index();
                } else { // single select
                    if (_oActive.length == 0) {
                        return null;
                    }
                    var _this = this,
                        _val = [];
                    _oActive.each(function(index, el) {
                        var _el = $(el);
                        if (_el.hasClass(_this._opt.active)) {
                            _val.push(_el.index());
                        }
                    });
                    return _val;
                }
            }
            // setValue
            var _oIndex = this._val_ul();
            if (!this.multi) { // single select
                var _selectedItem = this._wrap.children('li').eq(index);
                if (!_selectedItem.length)
                    return this;
                _selectedItem.addClass(this._opt.active).siblings('li').removeClass(this._opt.active);
                if (index !== _oIndex) {
                    this._triggerChange(index, _selectedItem);
                }
            } else { // multiple select
                if (index == null || index == '' || index == []) {
                    this._items.removeClass(this._opt.active);
                } else {
                    index = typeof index == 'object' ? index : [index];
                    this._items.removeClass(this._opt.active);
                    for (var i in index) {
                        var _no = index[i];
                        this._wrap.children('li').eq(_no).addClass(this._opt.active);
                    }
                }
                if (index !== _oIndex) {
                    this._triggerChange(index);
                }
            }
            // multiple
            return this;
        },

        // 获取或设置值
        val: function() {
            return this['_val_' + this._tag].apply(this, arguments);
        },

        // 值改变事件；
        change: function(value, item) {},

        // 点击事件；
        click: function(value, item) {},

        // 隐藏
        hide: function() {
            this._wrap.hide();
            return this;
        },

        // 显示
        show: function() {
            this._wrap.show();
            return this;
        }
    };
}(jQuery));

/*-----------------------------------------------Andrew_Html5shiv-------------------------------------------*/
(function(l, f) {
    function m() {
        var a = e.elements;
        return "string" == typeof a ? a.split(" ") : a
    }
    function i(a) {
        var b = n[a[o]];
        b || (b = {},
            h++, a[o] = h, n[h] = b);
        return b
    }
    function p(a, b, c) {
        b || (b = f);
        if (g) return b.createElement(a);
        c || (c = i(b));
        b = c.cache[a] ? c.cache[a].cloneNode() : r.test(a) ? (c.cache[a] = c.createElem(a)).cloneNode() : c.createElem(a);
        return b.canHaveChildren && !s.test(a) ? c.frag.appendChild(b) : b
    }
    function t(a, b) {
        if (!b.cache) b.cache = {},
            b.createElem = a.createElement,
            b.createFrag = a.createDocumentFragment,
            b.frag = b.createFrag();
        a.createElement = function(c) {
            return ! e.shivMethods ? b.createElem(c) : p(c, a, b)
        };
        a.createDocumentFragment = Function("h,f", "return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&(" + m().join().replace(/\w+/g,
            function(a) {
                b.createElem(a);
                b.frag.createElement(a);
                return 'c("' + a + '")'
            }) + ");return n}")(e, b.frag)
    }
    function q(a) {
        a || (a = f);
        var b = i(a);
        if (e.shivCSS && !j && !b.hasCSS) {
            var c, d = a;
            c = d.createElement("p");
            d = d.getElementsByTagName("head")[0] || d.documentElement;
            c.innerHTML = "x<style>article,aside,figcaption,figure,footer,header,main,hgroup,nav,section{display:block}mark{background:#FF0;color:#000}</style>";
            c = d.insertBefore(c.lastChild, d.firstChild);
            b.hasCSS = !!c
        }
        g || t(a, b);
        return a
    }
    var k = l.html5 || {},
        s = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,
        r = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,
        j, o = "_html5shiv",
        h = 0,
        n = {},
        g; (function() {
        try {
            var a = f.createElement("a");
            a.innerHTML = "<xyz></xyz>";
            j = "hidden" in a;
            var b;
            if (! (b = 1 == a.childNodes.length)) {
                f.createElement("a");
                var c = f.createDocumentFragment();
                b = "undefined" == typeof c.cloneNode || "undefined" == typeof c.createDocumentFragment || "undefined" == typeof c.createElement
            }
            g = b
        } catch(d) {
            g = j = !0
        }
    })();
    var e = {
        elements: k.elements || "abbr article aside audio bdi canvas data datalist details figcaption figure footer header main hgroup mark meter nav output progress section summary time video",
        version: "3.6.2pre Modfiy by Andrew.Kim",
        shivCSS: !1 !== k.shivCSS,
        supportsUnknownElements: g,
        shivMethods: !1 !== k.shivMethods,
        type: "default",
        shivDocument: q,
        createElement: p,
        createDocumentFragment: function(a, b) {
            a || (a = f);
            if (g) return a.createDocumentFragment();
            for (var b = b || i(a), c = b.frag.cloneNode(), d = 0, e = m(), h = e.length; d < h; d++) c.createElement(e[d]);
            return c
        }
    };
    l.html5 = e;
    q(f)
})(this, document);
